diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
index da0b0f03..17002c2b 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs
@@ -1687,6 +1687,253 @@ partial class Hlsl
[HlslIntrinsicName("all")]
public static bool All(Bool4x4 x) => default;
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool2 And(Bool2 left, Bool2 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool3 And(Bool3 left, Bool3 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool4 And(Bool4 left, Bool4 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool1x1 And(Bool1x1 left, Bool1x1 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool1x2 And(Bool1x2 left, Bool1x2 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool1x3 And(Bool1x3 left, Bool1x3 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool1x4 And(Bool1x4 left, Bool1x4 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool2x1 And(Bool2x1 left, Bool2x1 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool2x2 And(Bool2x2 left, Bool2x2 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool2x3 And(Bool2x3 left, Bool2x3 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool2x4 And(Bool2x4 left, Bool2x4 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool3x1 And(Bool3x1 left, Bool3x1 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool3x2 And(Bool3x2 left, Bool3x2 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool3x3 And(Bool3x3 left, Bool3x3 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool3x4 And(Bool3x4 left, Bool3x4 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool4x1 And(Bool4x1 left, Bool4x1 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool4x2 And(Bool4x2 left, Bool4x2 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool4x3 And(Bool4x3 left, Bool4x3 right) => default;
+
+ ///
+ /// Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.
+ ///
+ /// The first input vector or matrix value.
+ /// The second input vector or matrix value.
+ /// The new vector or matrix value with elements resulting from the boolean operation.
+ ///
+ /// For more info, see .
+ /// This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
+ ///
+ [HlslIntrinsicName("__And")]
+ public static Bool4x4 And(Bool4x4 left, Bool4x4 right) => default;
+
///
/// Determines if any components of the specified value are non-zero.
///
diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude
index 9d997908..0f405bcc 100644
--- a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude
+++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude
@@ -193,6 +193,41 @@ var Intrinsics = new[]
}
},
new
+ {
+ Name = "And",
+ HlslName = "__And",
+ Summary = "Performs a vectorized, non short-circuiting boolean 'AND' operation between two operands.",
+ Url = "https://learn.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-operators#boolean-math-operators",
+ Parameters = new[]
+ {
+ new { IsOut = false, Name = "left", Info = "The first input vector or matrix value." },
+ new { IsOut = false, Name = "right", Info = "The second input vector or matrix value." }
+ },
+ Returns = "The new vector or matrix value with elements resulting from the boolean operation.",
+ Overloads = new[]
+ {
+ new { Return = "Bool2", Params = new[] { "Bool2", "Bool2" } },
+ new { Return = "Bool3", Params = new[] { "Bool3", "Bool3" } },
+ new { Return = "Bool4", Params = new[] { "Bool4", "Bool4" } },
+ new { Return = "Bool1x1", Params = new[] { "Bool1x1", "Bool1x1" } },
+ new { Return = "Bool1x2", Params = new[] { "Bool1x2", "Bool1x2" } },
+ new { Return = "Bool1x3", Params = new[] { "Bool1x3", "Bool1x3" } },
+ new { Return = "Bool1x4", Params = new[] { "Bool1x4", "Bool1x4" } },
+ new { Return = "Bool2x1", Params = new[] { "Bool2x1", "Bool2x1" } },
+ new { Return = "Bool2x2", Params = new[] { "Bool2x2", "Bool2x2" } },
+ new { Return = "Bool2x3", Params = new[] { "Bool2x3", "Bool2x3" } },
+ new { Return = "Bool2x4", Params = new[] { "Bool2x4", "Bool2x4" } },
+ new { Return = "Bool3x1", Params = new[] { "Bool3x1", "Bool3x1" } },
+ new { Return = "Bool3x2", Params = new[] { "Bool3x2", "Bool3x2" } },
+ new { Return = "Bool3x3", Params = new[] { "Bool3x3", "Bool3x3" } },
+ new { Return = "Bool3x4", Params = new[] { "Bool3x4", "Bool3x4" } },
+ new { Return = "Bool4x1", Params = new[] { "Bool4x1", "Bool4x1" } },
+ new { Return = "Bool4x2", Params = new[] { "Bool4x2", "Bool4x2" } },
+ new { Return = "Bool4x3", Params = new[] { "Bool4x3", "Bool4x3" } },
+ new { Return = "Bool4x4", Params = new[] { "Bool4x4", "Bool4x4" } }
+ }
+ },
+ new
{
Name = "Any",
HlslName = "any",
@@ -2624,7 +2659,8 @@ var Intrinsics = new[]
new { Return = "Double4x4", Params = new[] { "Double4x4" } }
}
},
- new {
+ new
+ {
Name = "Select",
HlslName = "__Select",
Summary = "Creates a new vector or matrix value with elements selected between two specified source vector or matrix values based on an input boolean mask.",
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
index a4ca581a..a19e9f79 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
@@ -465,7 +465,23 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
// This path should only ever be reached for valid ones.
switch (method)
{
- // Select invocations are rewritten as follows:
+ // 'And' invocations are rewritten as follows:
+ //
+ // C#: Hlsl.And(left, right)
+ // HLSL (DX12): and(left, right)
+ // HLSL (D2D1): (left && right)
+ case "And":
+#if D3D12_SOURCE_GENERATOR
+ return updatedNode.WithExpression(IdentifierName("and"));
+#else
+ return
+ ParenthesizedExpression(
+ BinaryExpression(
+ SyntaxKind.LogicalAndExpression,
+ updatedNode.ArgumentList.Arguments[0].Expression,
+ updatedNode.ArgumentList.Arguments[1].Expression));
+#endif
+ // 'Select' invocations are rewritten as follows:
//
// C#: Hlsl.Select(mask, left, right)
// HLSL (DX12): select(mask, left, right)