Add new T4 template for void-returning intrinsics

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:33 +02:00
1 親 d51c0f5bf0
コミット a4582ee37a
6ファイル変更
+441 -2

検索条件に一致するファイルはありません

+9
ファイルの表示
@@ -23,6 +23,11 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Intrinsics\Hlsl.Void.g.cs">
<DependentUpon>Hlsl.Void.tt</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Intrinsics\Hlsl.g.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@@ -131,6 +136,10 @@
</ItemGroup>
<ItemGroup>
<None Update="Intrinsics\Hlsl.Void.tt">
<LastGenOutput>Hlsl.Void.g.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
</None>
<None Update="Intrinsics\Hlsl.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Hlsl.g.cs</LastGenOutput>
+308
ファイルの表示
@@ -0,0 +1,308 @@
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
namespace ComputeSharp;
/// <inheritdoc cref="Hlsl"/>
partial class Hlsl
{
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(float x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(float)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float2 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float2)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float4 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float4)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float1x1 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float1x1)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float1x2 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float1x2)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float1x3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float1x3)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float1x4 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float1x4)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float2x1 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float2x1)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float2x2 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float2x2)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float2x3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float2x3)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float2x4 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float2x4)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float3x1 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3x1)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float3x2 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3x2)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float3x3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3x3)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float3x4 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float3x4)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float4x1 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float4x1)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float4x2 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float4x2)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float4x3 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float4x3)})");
/// <summary>
/// Discards the current pixel if the specified value is less than zero.
/// </summary>
/// <param name="x">The specified value.</param>
/// <remarks>
/// <para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
/// <para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
/// <code>
/// Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
/// </code>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("clip")]
public static void Clip(Float4x4 x) => throw new InvalidExecutionContextException($"{typeof(Hlsl)}.{nameof(Clip)}({typeof(Float4x4)})");
}
+71
ファイルの表示
@@ -0,0 +1,71 @@
<#@include file="Hlsl.Void.ttinclude" #>
using ComputeSharp.Core.Intrinsics.Attributes;
using ComputeSharp.Exceptions;
namespace ComputeSharp;
/// <inheritdoc cref="Hlsl"/>
partial class Hlsl
{
<#
PushIndent(" ");
bool isFirst = true;
foreach (var intrinsic in Intrinsics)
{
foreach (var overload in intrinsic.Overloads)
{
if (isFirst) isFirst = false;
else WriteLine("");
WriteLine("/// <summary>");
WriteLine($"/// {intrinsic.Summary}");
WriteLine("/// </summary>");
foreach (var param in intrinsic.Parameters)
{
WriteLine($"/// <param name=\"{param.Name}\">{param.Info}</param>");
}
if (intrinsic.Remarks.Length > 0)
{
var lines = intrinsic.Remarks.Replace("\r", "").Split('\n');
WriteLine("/// <remarks>");
foreach (var line in lines)
{
string trimmedLine = line.Trim();
if (trimmedLine.Length > 0)
{
WriteLine($"/// {trimmedLine}");
}
}
WriteLine("/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>");
WriteLine("/// </remarks>");
}
else
{
WriteLine("/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>");
}
WriteLine($"[HlslIntrinsicName(\"{intrinsic.HlslName}\")]");
Write($"public static void {intrinsic.Name}(");
Write(string.Join(", ", intrinsic.Parameters.Zip(overload, (a, b) => $"{(a.IsOut ? "out " : "")}{b} {a.Name}")));
Write(")");
Write(" => throw new InvalidExecutionContextException(");
var parameters = string.Join(", ", overload.Select(t => $"{{typeof({t})}}"));
WriteLine($"$\"{{typeof(Hlsl)}}.{{nameof({intrinsic.Name})}}({parameters})\");");
}
}
PopIndent();
#>
}
+51
ファイルの表示
@@ -0,0 +1,51 @@
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".g.cs"#>
<#
var Intrinsics = new[]
{
new
{
Name = "Clip",
HlslName = "clip",
Summary = "Discards the current pixel if the specified value is less than zero.",
Remarks = @"
<para>Use the clip HLSL intrinsic function to simulate clipping planes if each component of the x parameter represents the distance from a plane.</para>
<para>Also, use the clip function to test for alpha behavior, as shown in the following example:</para>
<code>
Hlsl.Clip(color.A &lt; 0.1f ? -1 : 1);
</code>",
Parameters = new[]
{
new { IsOut = false, IsRef = false, Name = "x", Info = "The specified value." }
},
Overloads = new[]
{
new[] { "float" },
new[] { "Float2" },
new[] { "Float3" },
new[] { "Float4" },
new[] { "Float1x1" },
new[] { "Float1x2" },
new[] { "Float1x3" },
new[] { "Float1x4" },
new[] { "Float2x1" },
new[] { "Float2x2" },
new[] { "Float2x3" },
new[] { "Float2x4" },
new[] { "Float3x1" },
new[] { "Float3x2" },
new[] { "Float3x3" },
new[] { "Float3x4" },
new[] { "Float4x1" },
new[] { "Float4x2" },
new[] { "Float4x3" },
new[] { "Float4x4" }
}
}
};
#>
+1 -1
ファイルの表示
@@ -4,7 +4,7 @@ using ComputeSharp.Exceptions;
namespace ComputeSharp;
/// <inheritdoc cref="Hlsl"/>
public static partial class Hlsl
partial class Hlsl
{
/// <summary>
/// Returns the absolute value of the specified value.
+1 -1
ファイルの表示
@@ -5,7 +5,7 @@ using ComputeSharp.Exceptions;
namespace ComputeSharp;
/// <inheritdoc cref="Hlsl"/>
public static partial class Hlsl
partial class Hlsl
{
<#
PushIndent(" ");