diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs similarity index 98% rename from src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.Syntax.cs rename to src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs index 4b41b8ec..e7dc8be6 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs @@ -17,7 +17,7 @@ namespace ComputeSharp.SourceGenerators; public sealed partial class IShaderGenerator { /// - private static partial class TryGetBytecode + private static partial class LoadBytecode { /// /// Creates a instance for the TryGetBytecode method. @@ -41,14 +41,14 @@ public sealed partial class IShaderGenerator // This code produces a method declaration as follows: // - // readonly void global::ComputeSharp.__Internals.IShader.GetBytecode(ref TBytecodeLoader loader, int threadsX, int threadsY, int threadsZ) + // readonly void global::ComputeSharp.__Internals.IShader.LoadBytecode(ref TBytecodeLoader loader, int threadsX, int threadsY, int threadsZ) // { // // } return MethodDeclaration( PredefinedType(Token(SyntaxKind.VoidKeyword)), - Identifier("GetBytecode")) + Identifier("LoadBytecode")) .WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}"))) .AddModifiers(Token(SyntaxKind.ReadOnlyKeyword)) .AddTypeParameterListParameters(TypeParameter(Identifier("TBytecodeLoader"))) @@ -164,7 +164,7 @@ public sealed partial class IShaderGenerator /// A sequence of instances to create a new dynamic shader. private static ImmutableArray GetDynamicCompilationStatements() { - if (dynamicStatements.IsEmpty) + if (dynamicStatements.IsDefault) { // This code produces a method declaration as follows: // diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs similarity index 98% rename from src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.cs rename to src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs index 47fc3948..8a75495f 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateGetBytecodeMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs @@ -23,9 +23,9 @@ namespace ComputeSharp.SourceGenerators; public sealed partial class IShaderGenerator { /// - /// A helper with all logic to generate the TryGetBytecode method. + /// A helper with all logic to generate the LoadBytecode method. /// - private static partial class TryGetBytecode + private static partial class LoadBytecode { /// /// Gets the thread ids values for a given shader type, if available. diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs index 35b829a8..4507d253 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs @@ -66,7 +66,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax getDispatchIdMethod = GetDispatchId.GetSyntax(item.Info.Delegates); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getDispatchIdMethod, false); - context.AddSource($"{item.Hierarchy.FilenameHint}.GetDispatchId", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FilenameHint}.{nameof(GetDispatchId)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); }); // Get the dispatch data, HLSL source and embedded bytecode info. This info is computed on the @@ -99,7 +99,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator out ImmutableArray hlslSourceDiagnostics); // TryGetBytecode() info - ThreadIdsInfo threadIds = TryGetBytecode.GetInfo( + ThreadIdsInfo threadIds = LoadBytecode.GetInfo( item.Left.Symbol, !hlslSourceInfo.Delegates.IsEmpty, out ImmutableArray threadIdsDiagnostics); @@ -137,7 +137,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator item.Left.Root32BitConstantCount); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, loadDispatchDataMethod, item.Right); - context.AddSource($"{item.Left.Hierarchy.FilenameHint}.LoadDispatchData", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); + context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadDispatchData)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); }); // Get the filtered sequence to enable caching @@ -152,7 +152,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax buildHlslStringMethod = BuildHlslString.GetSyntax(item.Left.SourceInfo); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, buildHlslStringMethod, item.Right); - context.AddSource($"{item.Left.Hierarchy.FilenameHint}.BuildHlslString", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); + context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(BuildHlslString)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); }); // Get the dispatch metadata info @@ -173,7 +173,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator MethodDeclarationSyntax buildHlslStringMethod = LoadDispatchMetadata.GetSyntax(item.Left.MetadataInfo); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, buildHlslStringMethod, item.Right); - context.AddSource($"{item.Left.Hierarchy.FilenameHint}.LoadDispatchMetadata", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); + context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadDispatchMetadata)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8)); }); // Transform the raw HLSL source to compile @@ -187,7 +187,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator shaderBytecodeInfo .Select(static (item, token) => { - ImmutableArray bytecode = TryGetBytecode.GetBytecode(item.ThreadIds, item.Hlsl, out DiagnosticInfo? diagnostic); + ImmutableArray bytecode = LoadBytecode.GetBytecode(item.ThreadIds, item.Hlsl, out DiagnosticInfo? diagnostic); EmbeddedBytecodeInfo bytecodeInfo = new( item.ThreadIds.X, @@ -233,11 +233,11 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator // Generate the TryGetBytecode() methods context.RegisterSourceOutput(embeddedBytecode.Combine(supportsDynamicShaders), static (context, item) => { - MethodDeclarationSyntax tryGetBytecodeMethod = TryGetBytecode.GetSyntax(item.Left.BytecodeInfo, item.Right, out Func fixup); + MethodDeclarationSyntax tryGetBytecodeMethod = LoadBytecode.GetSyntax(item.Left.BytecodeInfo, item.Right, out Func fixup); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, tryGetBytecodeMethod, false); string text = fixup(compilationUnit); - context.AddSource($"{item.Left.Hierarchy.FilenameHint}.TryGetBytecode", SourceText.From(text, Encoding.UTF8)); + context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadBytecode)}", SourceText.From(text, Encoding.UTF8)); }); } }