From f5d69089554ec0d5d041c7a9ef2d5809af0ba194 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 3 Mar 2024 15:13:44 -0800 Subject: [PATCH] Add HLSL faceforward intrinsic --- src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs | 280 ++++++++++++++++++ .../Intrinsics/Hlsl.ttinclude | 37 +++ 2 files changed, 317 insertions(+) diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs index 26191a04..a4e9b674 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs @@ -7758,6 +7758,286 @@ partial class Hlsl [HlslIntrinsicName("exp2")] public static Float4x4 Exp2(Float4x4 x) => default; + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static float FaceForward(float n, float i, float ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float2 FaceForward(Float2 n, Float2 i, Float2 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float3 FaceForward(Float3 n, Float3 i, Float3 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float4 FaceForward(Float4 n, Float4 i, Float4 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float1x1 FaceForward(Float1x1 n, Float1x1 i, Float1x1 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float1x2 FaceForward(Float1x2 n, Float1x2 i, Float1x2 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float1x3 FaceForward(Float1x3 n, Float1x3 i, Float1x3 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float1x4 FaceForward(Float1x4 n, Float1x4 i, Float1x4 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float2x1 FaceForward(Float2x1 n, Float2x1 i, Float2x1 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float2x2 FaceForward(Float2x2 n, Float2x2 i, Float2x2 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float2x3 FaceForward(Float2x3 n, Float2x3 i, Float2x3 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float2x4 FaceForward(Float2x4 n, Float2x4 i, Float2x4 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float3x1 FaceForward(Float3x1 n, Float3x1 i, Float3x1 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float3x2 FaceForward(Float3x2 n, Float3x2 i, Float3x2 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float3x3 FaceForward(Float3x3 n, Float3x3 i, Float3x3 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float3x4 FaceForward(Float3x4 n, Float3x4 i, Float3x4 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float4x1 FaceForward(Float4x1 n, Float4x1 i, Float4x1 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float4x2 FaceForward(Float4x2 n, Float4x2 i, Float4x2 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float4x3 FaceForward(Float4x3 n, Float4x3 i, Float4x3 ng) => default; + + /// + /// Flips the surface-normal (if needed) to face in a direction opposite to , returns the result in . + /// + /// The resulting floating-point surface-normal vector. + /// A floating-point, incident vector that points from the view position to the shading position. + /// A floating-point surface-normal vector. + /// A floating-point, surface normal vector that is facing the view direction. + /// + /// 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("faceforward")] + public static Float4x4 FaceForward(Float4x4 n, Float4x4 i, Float4x4 ng) => default; + /// /// Gets the location of the first set bit starting from the highest order bit and working downward, per component. /// diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude index 96f1588d..ebcdf9d4 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude @@ -1101,6 +1101,43 @@ var Intrinsics = new[] } }, new + { + Name = "FaceForward", + HlslName = "faceforward", + Summary = "Flips the surface-normal (if needed) to face in a direction opposite to {param=i}, returns the result in {param=n}.", + Url = "https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-faceforward", + Parameters = new[] + { + new { IsOut = false, Name = "n", Info = "The resulting floating-point surface-normal vector." }, + new { IsOut = false, Name = "i", Info = "A floating-point, incident vector that points from the view position to the shading position." }, + new { IsOut = false, Name = "ng", Info = "A floating-point surface-normal vector." } + }, + Returns = "A floating-point, surface normal vector that is facing the view direction.", + Overloads = new[] + { + new { Return = "float", Params = new[] { "float", "float", "float" } }, + new { Return = "Float2", Params = new[] { "Float2", "Float2", "Float2" } }, + new { Return = "Float3", Params = new[] { "Float3", "Float3", "Float3" } }, + new { Return = "Float4", Params = new[] { "Float4", "Float4", "Float4" } }, + new { Return = "Float1x1", Params = new[] { "Float1x1", "Float1x1", "Float1x1" } }, + new { Return = "Float1x2", Params = new[] { "Float1x2", "Float1x2", "Float1x2" } }, + new { Return = "Float1x3", Params = new[] { "Float1x3", "Float1x3", "Float1x3" } }, + new { Return = "Float1x4", Params = new[] { "Float1x4", "Float1x4", "Float1x4" } }, + new { Return = "Float2x1", Params = new[] { "Float2x1", "Float2x1", "Float2x1" } }, + new { Return = "Float2x2", Params = new[] { "Float2x2", "Float2x2", "Float2x2" } }, + new { Return = "Float2x3", Params = new[] { "Float2x3", "Float2x3", "Float2x3" } }, + new { Return = "Float2x4", Params = new[] { "Float2x4", "Float2x4", "Float2x4" } }, + new { Return = "Float3x1", Params = new[] { "Float3x1", "Float3x1", "Float3x1" } }, + new { Return = "Float3x2", Params = new[] { "Float3x2", "Float3x2", "Float3x2" } }, + new { Return = "Float3x3", Params = new[] { "Float3x3", "Float3x3", "Float3x3" } }, + new { Return = "Float3x4", Params = new[] { "Float3x4", "Float3x4", "Float3x4" } }, + new { Return = "Float4x1", Params = new[] { "Float4x1", "Float4x1", "Float4x1" } }, + new { Return = "Float4x2", Params = new[] { "Float4x2", "Float4x2", "Float4x2" } }, + new { Return = "Float4x3", Params = new[] { "Float4x3", "Float4x3", "Float4x3" } }, + new { Return = "Float4x4", Params = new[] { "Float4x4", "Float4x4", "Float4x4" } } + } + }, + new { Name = "FirstBitHigh", HlslName = "firstbithigh",