diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index 1caa0d0e..b09d6663 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs index 9dc7506e..3edab2e8 100644 --- a/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs +++ b/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs @@ -127,16 +127,16 @@ namespace ComputeSharp.SourceGenerators.Diagnostics helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); /// - /// Gets a for an invalid usage. + /// Gets a for an invalid usage. /// - public static readonly DiagnosticDescriptor InvalidWarpIdsUsage = new( + public static readonly DiagnosticDescriptor InvalidGridIdsUsage = new( id: "CMPS0009", - title: "Invalid WarpIds usage", - messageFormat: "The WarpIds type can only be used within the main body of a compute shader", + title: "Invalid GridIds usage", + messageFormat: "The GridIds type can only be used within the main body of a compute shader", category: typeof(IComputeShader).FullName, defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, - description: "The WarpIds type can only be used within the main body of a compute shader.", + description: "The GridIds type can only be used within the main body of a compute shader.", helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); /// diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownKeywords.cs index 5aec5569..f0a3700e 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownKeywords.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownKeywords.cs @@ -39,7 +39,7 @@ namespace ComputeSharp.SourceGenerators.Mappings knownKeywords.Add(nameof(ThreadIds)); knownKeywords.Add(nameof(GroupIds)); knownKeywords.Add(nameof(GroupSize)); - knownKeywords.Add(nameof(WarpIds)); + knownKeywords.Add(nameof(GridIds)); // HLSL intrinsics method names foreach (var method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static)) diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index 2f686b1c..cc35c9dc 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -21,7 +21,7 @@ namespace ComputeSharp.SourceGenerators.Mappings { typeof(ThreadIds), typeof(GroupIds), - typeof(WarpIds) + typeof(GridIds) }; /// diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ConstantPropertyRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ConstantPropertyRewriter.cs index a62cbeb2..4d2449e4 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ConstantPropertyRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ConstantPropertyRewriter.cs @@ -86,7 +86,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters _ when typeName == typeof(ThreadIds).FullName => InvalidThreadIdsUsage, _ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage, _ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage, - _ when typeName == typeof(WarpIds).FullName => InvalidWarpIdsUsage, + _ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage, _ => null }; diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs index ad67c0b3..0c9febca 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs @@ -48,9 +48,9 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint __{nameof(GroupIds)}__get_Index : SV_GroupIndex"))); } - if (this.shaderSourceRewriter.IsWarpIdsUsed) + if (this.shaderSourceRewriter.IsGridIdsUsed) { - updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(WarpIds)} : SV_GroupID"))); + updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(GridIds)} : SV_GroupID"))); } return updatedNode; diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 3923134e..e35144d5 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -118,9 +118,9 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters public bool IsGroupIdsIndexUsed { get; private set; } /// - /// Gets whether or not the shader uses at least once. + /// Gets whether or not the shader uses at least once. /// - public bool IsWarpIdsUsed { get; set; } + public bool IsGridIdsUsed { get; set; } /// public MethodDeclarationSyntax? Visit(MethodDeclarationSyntax? node) @@ -277,7 +277,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters if (mapping == $"__{nameof(GroupIds)}__get_Index") IsGroupIdsIndexUsed = true; else if (typeName == typeof(GroupIds).FullName) IsGroupIdsUsed = true; - else if (typeName == typeof(WarpIds).FullName) IsWarpIdsUsed = true; + else if (typeName == typeof(GridIds).FullName) IsGridIdsUsed = true; // Check that the dispatch info types are only used from the main shader body if (!this.isEntryPoint || this.localFunctionDepth > 0) @@ -287,7 +287,7 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters _ when typeName == typeof(ThreadIds).FullName => InvalidThreadIdsUsage, _ when typeName == typeof(GroupIds).FullName => InvalidGroupIdsUsage, _ when typeName == typeof(GroupSize).FullName => InvalidGroupSizeUsage, - _ when typeName == typeof(WarpIds).FullName => InvalidWarpIdsUsage, + _ when typeName == typeof(GridIds).FullName => InvalidGridIdsUsage, _ => null }; diff --git a/src/ComputeSharp/Core/Dispatch/WarpIds.cs b/src/ComputeSharp/Core/Dispatch/GridIds.cs similarity index 80% rename from src/ComputeSharp/Core/Dispatch/WarpIds.cs rename to src/ComputeSharp/Core/Dispatch/GridIds.cs index 5777fe5b..5e6f82e5 100644 --- a/src/ComputeSharp/Core/Dispatch/WarpIds.cs +++ b/src/ComputeSharp/Core/Dispatch/GridIds.cs @@ -3,203 +3,203 @@ namespace ComputeSharp { /// - /// A that indicates the ids of a given dispatch warp (a group of threads). + /// A that indicates the ids of the current thread group within the dispatch grid. /// - public static class WarpIds + public static class GridIds { /// /// Gets the X id of the current thread with respect to the dispatch group. /// - public static int X => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(X)}"); + public static int X => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(X)}"); /// /// Gets the Y id of the current thread with respect to the dispatch group. /// - public static int Y => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(Y)}"); + public static int Y => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(Y)}"); /// /// Gets the Z id of the current thread with respect to the dispatch group. /// - public static int Z => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(Z)}"); + public static int Z => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(Z)}"); /// /// Gets a value with the components , . /// - public static Int2 XX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XX)}"); + public static Int2 XX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XX)}"); /// /// Gets a value with the components , . /// - public static Int2 XY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XY)}"); + public static Int2 XY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XY)}"); /// /// Gets a value with the components , . /// - public static Int2 XZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XZ)}"); + public static Int2 XZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XZ)}"); /// /// Gets a value with the components , . /// - public static Int2 YX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YX)}"); + public static Int2 YX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YX)}"); /// /// Gets a value with the components , . /// - public static Int2 YY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YY)}"); + public static Int2 YY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YY)}"); /// /// Gets a value with the components , . /// - public static Int2 YZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YZ)}"); + public static Int2 YZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YZ)}"); /// /// Gets a value with the components , . /// - public static Int2 ZX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZX)}"); + public static Int2 ZX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZX)}"); /// /// Gets a value with the components , . /// - public static Int2 ZY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZY)}"); + public static Int2 ZY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZY)}"); /// /// Gets a value with the components , . /// - public static Int2 ZZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZZ)}"); + public static Int2 ZZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 XXX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XXX)}"); + public static Int3 XXX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XXX)}"); /// /// Gets a value with the components , , . /// - public static Int3 XXY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XXY)}"); + public static Int3 XXY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XXY)}"); /// /// Gets a value with the components , , . /// - public static Int3 XXZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XXZ)}"); + public static Int3 XXZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XXZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 XYX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XYX)}"); + public static Int3 XYX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XYX)}"); /// /// Gets a value with the components , , . /// - public static Int3 XYY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XYY)}"); + public static Int3 XYY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XYY)}"); /// /// Gets a value with the components , , . /// - public static Int3 XYZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XYZ)}"); + public static Int3 XYZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XYZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 XZX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XZX)}"); + public static Int3 XZX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XZX)}"); /// /// Gets a value with the components , , . /// - public static Int3 XZY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XZY)}"); + public static Int3 XZY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XZY)}"); /// /// Gets a value with the components , , . /// - public static Int3 XZZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(XZZ)}"); + public static Int3 XZZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(XZZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 YXX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YXX)}"); + public static Int3 YXX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YXX)}"); /// /// Gets a value with the components , , . /// - public static Int3 YXY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YXY)}"); + public static Int3 YXY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YXY)}"); /// /// Gets a value with the components , , . /// - public static Int3 YXZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YXZ)}"); + public static Int3 YXZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YXZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 YYX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YYX)}"); + public static Int3 YYX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YYX)}"); /// /// Gets a value with the components , , . /// - public static Int3 YYY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YYY)}"); + public static Int3 YYY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YYY)}"); /// /// Gets a value with the components , , . /// - public static Int3 YYZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YYZ)}"); + public static Int3 YYZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YYZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 YZX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YZX)}"); + public static Int3 YZX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YZX)}"); /// /// Gets a value with the components , , . /// - public static Int3 YZY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YZY)}"); + public static Int3 YZY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YZY)}"); /// /// Gets a value with the components , , . /// - public static Int3 YZZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(YZZ)}"); + public static Int3 YZZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(YZZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZXX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZXX)}"); + public static Int3 ZXX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZXX)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZXY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZXY)}"); + public static Int3 ZXY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZXY)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZXZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZXZ)}"); + public static Int3 ZXZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZXZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZYX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZYX)}"); + public static Int3 ZYX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZYX)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZYY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZYY)}"); + public static Int3 ZYY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZYY)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZYZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZYZ)}"); + public static Int3 ZYZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZYZ)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZZX => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZZX)}"); + public static Int3 ZZX => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZZX)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZZY => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZZY)}"); + public static Int3 ZZY => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZZY)}"); /// /// Gets a value with the components , , . /// - public static Int3 ZZZ => throw new InvalidExecutionContextException($"{typeof(WarpIds)}.{nameof(ZZZ)}"); + public static Int3 ZZZ => throw new InvalidExecutionContextException($"{typeof(GridIds)}.{nameof(ZZZ)}"); } } diff --git a/tests/ComputeSharp.Tests.Internals.SourceGenerators/DiagnosticsTests.cs b/tests/ComputeSharp.Tests.Internals.SourceGenerators/DiagnosticsTests.cs index 2eaa16b3..f26ed063 100644 --- a/tests/ComputeSharp.Tests.Internals.SourceGenerators/DiagnosticsTests.cs +++ b/tests/ComputeSharp.Tests.Internals.SourceGenerators/DiagnosticsTests.cs @@ -141,7 +141,7 @@ namespace ComputeSharp.Tests.Internals [DataRow(nameof(ThreadIds), "CMPS0006")] [DataRow(nameof(GroupIds), "CMPS0007")] [DataRow(nameof(GroupSize), "CMPS0008")] - [DataRow(nameof(WarpIds), "CMPS0009")] + [DataRow(nameof(GridIds), "CMPS0009")] public void InvalidDispatchInfoUsage_LocalFunction(string typeName, string diagnosticsId) { string source = $@" @@ -175,7 +175,7 @@ namespace ComputeSharp.Tests.Internals [DataRow(nameof(ThreadIds), "CMPS0006")] [DataRow(nameof(GroupIds), "CMPS0007")] [DataRow(nameof(GroupSize), "CMPS0008")] - [DataRow(nameof(WarpIds), "CMPS0009")] + [DataRow(nameof(GridIds), "CMPS0009")] public void InvalidDispatchInfoUsage_StaticMethod(string typeName, string diagnosticsId) { string source = $@"