From be0ca6ed153364d31213fa323719f3296137928f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 26 Apr 2022 15:02:09 +0200 Subject: [PATCH] Add f32tof16 and f16tof32 intrinsics --- src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs | 72 +++++++++++++++++++ .../Intrinsics/Hlsl.ttinclude | 36 ++++++++++ 2 files changed, 108 insertions(+) diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs index 41a98d1b..2b45127f 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs @@ -5806,6 +5806,78 @@ partial class Hlsl [HlslIntrinsicName("firstbitlow")] public static UInt4 FirstBitLow(UInt4 value) => default; + /// + /// Converts the input float value into a 16-bit floating point value stored in the lower half of the returned uint value. + /// + /// The input value. + /// The converted value, stored in the low-half of the uint. + /// 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("f32tof16")] + public static float Float32ToFloat16(uint x) => default; + + /// + /// Converts the input float value into a 16-bit floating point value stored in the lower half of the returned uint value. + /// + /// The input value. + /// The converted value, stored in the low-half of the uint. + /// 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("f32tof16")] + public static Float2 Float32ToFloat16(UInt2 x) => default; + + /// + /// Converts the input float value into a 16-bit floating point value stored in the lower half of the returned uint value. + /// + /// The input value. + /// The converted value, stored in the low-half of the uint. + /// 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("f32tof16")] + public static Float3 Float32ToFloat16(UInt3 x) => default; + + /// + /// Converts the input float value into a 16-bit floating point value stored in the lower half of the returned uint value. + /// + /// The input value. + /// The converted value, stored in the low-half of the uint. + /// 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("f32tof16")] + public static Float4 Float32ToFloat16(UInt4 x) => default; + + /// + /// Converts the 16-bit floating point value stored in the lower half of the input uint value to a float. + /// + /// The input value. + /// The converted value. + /// 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("f16tof32")] + public static float Float16ToFloat32(uint x) => default; + + /// + /// Converts the 16-bit floating point value stored in the lower half of the input uint value to a float. + /// + /// The input value. + /// The converted value. + /// 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("f16tof32")] + public static Float2 Float16ToFloat32(UInt2 x) => default; + + /// + /// Converts the 16-bit floating point value stored in the lower half of the input uint value to a float. + /// + /// The input value. + /// The converted value. + /// 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("f16tof32")] + public static Float3 Float16ToFloat32(UInt3 x) => default; + + /// + /// Converts the 16-bit floating point value stored in the lower half of the input uint value to a float. + /// + /// The input value. + /// The converted value. + /// 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("f16tof32")] + public static Float4 Float16ToFloat32(UInt4 x) => default; + /// /// Returns the largest integer that is less than or equal to the specified value. /// diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude index 470fdde4..e63e65e9 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude @@ -1082,6 +1082,42 @@ var Intrinsics = new[] } }, new + { + Name = "Float32ToFloat16", + HlslName = "f32tof16", + Summary = "Converts the input float value into a 16-bit floating point value stored in the lower half of the returned uint value.", + Parameters = new[] + { + new { IsOut = false, Name = "x", Info = "The input value." } + }, + Returns = "The converted value, stored in the low-half of the uint.", + Overloads = new[] + { + new { Return = "float", Params = new[] { "uint" } }, + new { Return = "Float2", Params = new[] { "UInt2" } }, + new { Return = "Float3", Params = new[] { "UInt3" } }, + new { Return = "Float4", Params = new[] { "UInt4" } } + } + }, + new + { + Name = "Float16ToFloat32", + HlslName = "f16tof32", + Summary = "Converts the 16-bit floating point value stored in the lower half of the input uint value to a float.", + Parameters = new[] + { + new { IsOut = false, Name = "x", Info = "The input value." } + }, + Returns = "The converted value.", + Overloads = new[] + { + new { Return = "float", Params = new[] { "uint" } }, + new { Return = "Float2", Params = new[] { "UInt2" } }, + new { Return = "Float3", Params = new[] { "UInt3" } }, + new { Return = "Float4", Params = new[] { "UInt4" } } + } + }, + new { Name = "Floor", HlslName = "floor",