From 6f39eee10616d69414f0410d7e927028e314d5b8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 9 Apr 2022 13:58:15 +0200 Subject: [PATCH] Rename BuildHlslString to BuildHlslSource --- ...haderGenerator.CreateLoadBytecodeMethod.Syntax.cs | 2 +- .../Shaders/Interop/ReflectionServices.cs | 2 +- .../Translation/__Internals/ShaderCompiler.cs | 2 +- ...rGenerator.CreateBuildHlslSourceMethod.Syntax.cs} | 10 +++++----- ... IShaderGenerator.CreateBuildHlslSourceMethod.cs} | 4 ++-- ...haderGenerator.CreateLoadBytecodeMethod.Syntax.cs | 2 +- .../IShaderGenerator.cs | 12 ++++++------ .../ShaderMethodSourceGenerator.cs | 4 ++-- .../Core/Interfaces/__Internals/IShader.cs | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) rename src/ComputeSharp.SourceGenerators/{IShaderGenerator.CreateBuildHlslStringMethod.Syntax.cs => IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs} (98%) rename src/ComputeSharp.SourceGenerators/{IShaderGenerator.CreateBuildHlslStringMethod.cs => IShaderGenerator.CreateBuildHlslSourceMethod.cs} (99%) diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs index 2d8b31c8..767c3cae 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs @@ -23,7 +23,7 @@ partial class ID2D1ShaderGenerator /// /// The input bytecode info. /// An opaque instance to transform the final tree into text. - /// The resulting instance for the BuildHlslString method. + /// The resulting instance for the BuildHlslSource method. public static MethodDeclarationSyntax GetSyntax(EmbeddedBytecodeInfo bytecodeInfo, out Func fixup) { BlockSyntax block = GetShaderBytecodeBody(bytecodeInfo, out string? bytecodeLiterals); diff --git a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs index e6b46765..51a04792 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs @@ -104,7 +104,7 @@ public static class ReflectionServices private static unsafe ShaderInfo GetNonGenericShaderInfo(in T shader) where T : struct, IShader { - Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder shaderSource, 1, 1, 1); + Unsafe.AsRef(in shader).BuildHlslSource(out ArrayPoolStringBuilder shaderSource, 1, 1, 1); using ComPtr dxcBlobBytecode = Shaders.Translation.ShaderCompiler.Instance.Compile(shaderSource.WrittenSpan); diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/__Internals/ShaderCompiler.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/__Internals/ShaderCompiler.cs index b0b3bddd..e93dc7f6 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Translation/__Internals/ShaderCompiler.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Translation/__Internals/ShaderCompiler.cs @@ -27,7 +27,7 @@ public static class ShaderCompiler where TLoader : struct, IBytecodeLoader where T : struct, IShader { - Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder builder, threadsX, threadsY, threadsZ); + Unsafe.AsRef(in shader).BuildHlslSource(out ArrayPoolStringBuilder builder, threadsX, threadsY, threadsZ); using ComPtr dxcBlobBytecode = Shaders.Translation.ShaderCompiler.Instance.Compile(builder.WrittenSpan); diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs similarity index 98% rename from src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.Syntax.cs rename to src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs index ce88d435..d9e61b14 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs @@ -15,14 +15,14 @@ namespace ComputeSharp.SourceGenerators; public sealed partial class IShaderGenerator { /// - internal static partial class BuildHlslString + internal static partial class BuildHlslSource { /// - /// Creates a instance for the BuildHlslString method. + /// Creates a instance for the BuildHlslSource method. /// /// The input instance to use. /// Indicates whether or not dynamic shaders are supported. - /// The resulting instance for the BuildHlslString method. + /// The resulting instance for the BuildHlslSource method. public static MethodDeclarationSyntax GetSyntax(HlslShaderSourceInfo hlslSourceInfo, bool supportsDynamicShaders) { // Generate the necessary body statements depending on whether dynamic shaders are supported @@ -32,14 +32,14 @@ public sealed partial class IShaderGenerator // This code produces a method declaration as follows: // - // readonly void global::ComputeSharp.__Internals.IShader.BuildHlslString(out global::ComputeSharp.__Internals.ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ) + // readonly void global::ComputeSharp.__Internals.IShader.BuildHlslSource(out global::ComputeSharp.__Internals.ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ) // { // // } return MethodDeclaration( PredefinedType(Token(SyntaxKind.VoidKeyword)), - Identifier("BuildHlslString")) + Identifier("BuildHlslSource")) .WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}"))) .AddModifiers(Token(SyntaxKind.ReadOnlyKeyword)) .AddParameterListParameters( diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs similarity index 99% rename from src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.cs rename to src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index 89bff376..4b96d13e 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslStringMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -23,9 +23,9 @@ namespace ComputeSharp.SourceGenerators; public sealed partial class IShaderGenerator { /// - /// A helper with all logic to generate the BuildHlslString method. + /// A helper with all logic to generate the BuildHlslSource method. /// - internal static partial class BuildHlslString + internal static partial class BuildHlslSource { /// /// Gathers all necessary information on a transpiled HLSL source for a given shader type. diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs index 4b2378e4..a49da76d 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs @@ -22,7 +22,7 @@ public sealed partial class IShaderGenerator /// The input instance. /// Indicates whether or not dynamic shaders are supported. /// An opaque instance to transform the final tree into text. - /// The resulting instance for the BuildHlslString method. + /// The resulting instance for the BuildHlslSource method. public static MethodDeclarationSyntax GetSyntax(EmbeddedBytecodeInfo bytecodeInfo, bool supportsDynamicShaders, out Func fixup) { BlockSyntax block = GetShaderBytecodeBody(bytecodeInfo, supportsDynamicShaders, out string? bytecodeLiterals); diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs index df87587d..3d056be6 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs @@ -100,8 +100,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator token.ThrowIfCancellationRequested(); - // BuildHlslString() info - HlslShaderSourceInfo hlslSourceInfo = BuildHlslString.GetInfo( + // BuildHlslSource() info + HlslShaderSourceInfo hlslSourceInfo = BuildHlslSource.GetInfo( item.Right, item.Left.Left.Syntax, item.Left.Left.Symbol, @@ -161,13 +161,13 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator .Select(static (item, token) => (item.Left.Dispatch.Hierarchy, item.Left.Hlsl, item.Right)) .WithComparers(HierarchyInfo.Comparer.Default, HlslShaderSourceInfo.Comparer.Default, EqualityComparer.Default); - // Generate the BuildHlslString() methods + // Generate the BuildHlslSource() methods context.RegisterSourceOutput(hlslSourceInfo.Combine(canUseSkipLocalsInit), static (context, item) => { - MethodDeclarationSyntax buildHlslStringMethod = BuildHlslString.GetSyntax(item.Left.SourceInfo, item.Left.SupportsDynamicShaders); + MethodDeclarationSyntax buildHlslStringMethod = BuildHlslSource.GetSyntax(item.Left.SourceInfo, item.Left.SupportsDynamicShaders); CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, buildHlslStringMethod, item.Right); - context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(BuildHlslString)}", compilationUnit.ToFullString()); + context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(BuildHlslSource)}", compilationUnit.ToFullString()); }); // Get the dispatch metadata info @@ -199,7 +199,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator // Transform the raw HLSL source to compile IncrementalValuesProvider<(HierarchyInfo Hierarchy, string Hlsl, ThreadIdsInfo ThreadIds)> shaderBytecodeInfo = shaderInfo - .Select(static (item, token) => (item.Dispatch.Hierarchy, BuildHlslString.GetNonDynamicHlslSource(item.Hlsl), item.ThreadIds)) + .Select(static (item, token) => (item.Dispatch.Hierarchy, BuildHlslSource.GetNonDynamicHlslSource(item.Hlsl), item.ThreadIds)) .WithComparers(HierarchyInfo.Comparer.Default, EqualityComparer.Default, ThreadIdsInfo.Comparer.Default); // Compile the requested shader bytecodes diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index 457513f4..9ac711ef 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -96,8 +96,8 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator // Explore the syntax tree and extract the processed info var semanticModel = new SemanticModelProvider(compilation); var (entryPoint, dependentMethods) = GetProcessedMethods(methodDeclaration, semanticModel, discoveredTypes, constantDefinitions, out diagnostics); - var definedTypes = IShaderGenerator.BuildHlslString.GetDeclaredTypes(discoveredTypes); - var definedConstants = IShaderGenerator.BuildHlslString.GetDefinedConstants(constantDefinitions); + var definedTypes = IShaderGenerator.BuildHlslSource.GetDeclaredTypes(discoveredTypes); + var definedConstants = IShaderGenerator.BuildHlslSource.GetDefinedConstants(constantDefinitions); return new( methodSymbol.GetFullMetadataName(includeParameters: true), diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs b/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs index 7c54eff6..e688929b 100644 --- a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs +++ b/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs @@ -73,7 +73,7 @@ public interface IShader /// The number of threads in each thread group for the Z axis. [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("This method is not intended to be called directly by user code")] - void BuildHlslString(out ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ) + void BuildHlslSource(out ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ) #if NET6_0_OR_GREATER { throw new NotImplementedException();