Skip to content

Commit

Permalink
Add '[ConstantExpected]' attributes to 'D2D' intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 21, 2024
1 parent 763c856 commit 44ebeaf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ComputeSharp.D2D1/Intrinsics/D2D.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using ComputeSharp.Core.Intrinsics.Attributes;

#pragma warning disable IDE0022
Expand All @@ -17,7 +18,7 @@ public static class D2D
/// <returns>The color from the target input at the current coordinate, in <c>INPUTN</c> format.</returns>
/// <remarks>This method is only available for simple inputs.</remarks>
[HlslIntrinsicName("D2DGetInput")]
public static Float4 GetInput(int index) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(GetInput)}({typeof(int)})");
public static Float4 GetInput([ConstantExpected(Min = 0, Max = 7)] int index) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(GetInput)}({typeof(int)})");

/// <summary>
/// Returns the coordinate of the input texture at a specific index.
Expand All @@ -26,7 +27,7 @@ public static class D2D
/// <returns>The input coordinate, in <c>TEXCOORDN</c> format.</returns>
/// <remarks>This method is only available for complex inputs.</remarks>
[HlslIntrinsicName("D2DGetInputCoordinate")]
public static Float4 GetInputCoordinate(int index) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(GetInputCoordinate)}({typeof(int)})");
public static Float4 GetInputCoordinate([ConstantExpected(Min = 0, Max = 7)] int index) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(GetInputCoordinate)}({typeof(int)})");

/// <summary>
/// Returns the value of the current scene position.
Expand All @@ -44,7 +45,7 @@ public static class D2D
/// <returns>The sampled value from the texture, in <c>TEXCOORDN</c> format.</returns>
/// <remarks>This method is only available for complex inputs.</remarks>
[HlslIntrinsicName("D2DSampleInput")]
public static Float4 SampleInput(int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInput)}({typeof(int)}, {typeof(Float2)})");
public static Float4 SampleInput([ConstantExpected(Min = 0, Max = 7)] int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInput)}({typeof(int)}, {typeof(Float2)})");

/// <summary>
/// Samples the input texture at a specified index and at a given offset from the input coordinate.
Expand All @@ -54,7 +55,7 @@ public static class D2D
/// <returns>The sampled value from the texture, in <c>TEXCOORDN</c> format.</returns>
/// <remarks>This method is only available for complex inputs.</remarks>
[HlslIntrinsicName("D2DSampleInputAtOffset")]
public static Float4 SampleInputAtOffset(int index, Float2 offset) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInputAtOffset)}({typeof(int)}, {typeof(Float2)})");
public static Float4 SampleInputAtOffset([ConstantExpected(Min = 0, Max = 7)] int index, Float2 offset) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInputAtOffset)}({typeof(int)}, {typeof(Float2)})");

/// <summary>
/// Samples the input texture at a specified index and at an absolute scene position (not an input-relative position).
Expand All @@ -64,5 +65,5 @@ public static class D2D
/// <returns>The sampled value from the texture, in <c>TEXCOORDN</c> format.</returns>
/// <remarks>This method is only available for complex inputs.</remarks>
[HlslIntrinsicName("D2DSampleInputAtPosition")]
public static Float4 SampleInputAtPosition(int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInputAtPosition)}({typeof(int)}, {typeof(Float2)})");
public static Float4 SampleInputAtPosition([ConstantExpected(Min = 0, Max = 7)] int index, Float2 uv) => throw new InvalidExecutionContextException($"{typeof(D2D)}.{nameof(SampleInputAtPosition)}({typeof(int)}, {typeof(Float2)})");
}

0 comments on commit 44ebeaf

Please sign in to comment.