Switched ThreadIds to static type

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-13 19:07:53 +01:00
1 親 bbc8832023
コミット c6aa194749
6ファイル変更
+73 -78

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

+9 -23
ファイルの表示
@@ -10,20 +10,6 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
/// </summary>
internal sealed class ExecuteMethodRewriter : CSharpSyntaxRewriter
{
/// <summary>
/// The identifier name for the input <see langword="uint3"/> parameter.
/// </summary>
private readonly string threadIdsIdentifier;
/// <summary>
/// Creates a new <see cref="ExecuteMethodRewriter"/> instance with the specified parameters.
/// </summary>
/// <param name="threadIdsIdentifier">The identifier name for the input <see langword="uint3"/> parameter.</param>
public ExecuteMethodRewriter(string threadIdsIdentifier)
{
this.threadIdsIdentifier = threadIdsIdentifier;
}
/// <inheritdoc cref="CSharpSyntaxRewriter.Visit(SyntaxNode?)"/>
public TNode? Visit<TNode>(TNode? node)
where TNode : SyntaxNode
@@ -32,11 +18,11 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
}
/// <inheritdoc/>
public override SyntaxNode VisitParameter(ParameterSyntax node)
public override SyntaxNode? VisitParameterList(ParameterListSyntax node)
{
var updatedNode = (ParameterSyntax)base.VisitParameter(node)!;
var updatedNode = (ParameterListSyntax)base.VisitParameterList(node)!;
return updatedNode.WithIdentifier(Identifier($"{updatedNode.Identifier.Text} : SV_DispatchThreadId"));
return updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(ThreadIds)} : SV_DispatchThreadID")));
}
/// <inheritdoc/>
@@ -48,9 +34,9 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
// check to ensure that invocation outside of the requested range are discarded.
// The following snippet creates this prologue before the user provided body:
//
// if (ids.X < __x &&
// ids.Y < __y &&
// ids.Z < __z)
// if (ThreadIds.x < __x &&
// ThreadIds.y < __y &&
// ThreadIds.z < __z)
// {
// <body>
// }
@@ -60,19 +46,19 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("x")),
IdentifierName("__x")),
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("y")),
IdentifierName("__y"))),
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("z")),
IdentifierName("__z")));