From 8aa6a5936a4be24a9642d24ae42e6bc53783abf4 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 2 Apr 2022 12:59:33 +0200 Subject: [PATCH] Add D2D1 intrinsics --- .../ComputeSharp.D2D1Interop.csproj | 3 + .../Intrinsics/D2D1.cs | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/ComputeSharp.D2D1Interop/Intrinsics/D2D1.cs diff --git a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj index 16e8e2af..fb8c0b90 100644 --- a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj +++ b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj @@ -14,4 +14,7 @@ + + + diff --git a/src/ComputeSharp.D2D1Interop/Intrinsics/D2D1.cs b/src/ComputeSharp.D2D1Interop/Intrinsics/D2D1.cs new file mode 100644 index 00000000..a0dca8fb --- /dev/null +++ b/src/ComputeSharp.D2D1Interop/Intrinsics/D2D1.cs @@ -0,0 +1,60 @@ +using ComputeSharp.Exceptions; + +namespace ComputeSharp.D2D1Interop; + +/// +/// A that maps the supported HLSL intrinsic functions specifically for D2D1 shaders. +/// +/// For more info, see . +public static class D2D1 +{ + /// + /// Returns the color of the input texture at a specific index, for the curreent coordinate. + /// + /// The index of the input texture to get the input from. + /// The color from the target input at the current coordinate, in INPUTN format. + /// This method is only available for simple inputs. + public static Float4 GetInput(int index) => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(GetInput)}({typeof(int)})"); + + /// + /// Returns the coordinate of the input texture at a specific index. + /// + /// The index of the input texture to get the coordinate for. + /// The input coordinate, in TEXCOORDN format. + /// This method is only available for complex inputs. + public static Float4 GetInputCoordinate(int index) => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(GetInputCoordinate)}({typeof(int)})"); + + /// + /// Returns the value of the current scene position. + /// + /// The current scene position, in SCENE_POSITION format. + /// This method is only available when is used on the shader type. + public static Float4 GetScenePosition() => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(GetScenePosition)}()"); + + /// + /// Samples the input texture at a specified index and at a given position. + /// + /// The index of the input texture to sample. + /// The normalized coordinate to use to sample the texture. + /// The sampled value from the texture, in TEXCOORDN format. + /// This method is only available for complex inputs. + public static Float4 SampleInput(int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(SampleInput)}({typeof(int)}, {typeof(Float2)})"); + + /// + /// Samples the input texturee at a specified index and at a given offset from the input coordinate. + /// + /// The index of the input texture to sample. + /// The normalized offset to use to sample the texture. + /// The sampled value from the texture, in TEXCOORDN format. + /// This method is only available for simple inputs. + public static Float4 SampleInputAtOffset(int index, Float2 offset) => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(SampleInputAtOffset)}({typeof(int)}, {typeof(Float2)})"); + + /// + /// Samples the input texture at a specified index and at an absolute scene position (not an input-relative position). + /// + /// The index of the input texture to sample. + /// The normalized coordinate to use to sample the texture. + /// The sampled value from the texture, in TEXCOORDN format. + /// This method is only available for complex inputs. + public static Float4 SampleInputAtPosition(int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D1)}.{nameof(SampleInputAtPosition)}({typeof(int)}, {typeof(Float2)})"); +}