Update and rename source generator files

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-28 00:36:56 +02:00
1 親 60028ce00c
コミット e69f083b29
3ファイル変更
+11 -13

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

@@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
/// <inheritdoc/>
partial class BuildHlslSource
partial class HlslSource
{
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>HlslSource</c> property.
@@ -29,7 +29,7 @@ partial class ID2D1ShaderGenerator
//
// readonly string global::ComputeSharp.D2D1.__Internals.ID2D1Shader.HlslSource => <HLSL_SOURCE>;
return
PropertyDeclaration(PredefinedType(Token(SyntaxKind.VoidKeyword)), Identifier("HlslSource"))
PropertyDeclaration(PredefinedType(Token(SyntaxKind.StringKeyword)), Identifier("HlslSource"))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithExpressionBody(ArrowExpressionClause(LiteralExpression(SyntaxKind.StringLiteralExpression, hlslSourceLiteralExpression)))
@@ -14,17 +14,15 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.SourceGenerators;
/// <inheritdoc/>
partial class ID2D1ShaderGenerator
{
/// <summary>
/// A helper with all logic to generate the <c>BuildHlslSource</c> method.
/// A helper with all logic to generate the <c>HlslSource</c> property.
/// </summary>
private static partial class BuildHlslSource
private static partial class HlslSource
{
/// <summary>
/// Gathers all necessary information on a transpiled HLSL source for a given shader type.
+7 -7
ファイルの表示
@@ -107,8 +107,8 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
inputCount,
out ImmutableArray<ResourceTextureDescription> resourceTextureDescriptions);
// Get HLSL source for BuildHlslSource()
string hlslSource = BuildHlslSource.GetHlslSource(
// Get HLSL source for HlslSource
string hlslSource = HlslSource.GetHlslSource(
diagnostics,
context.SemanticModel.Compilation,
typeDeclaration,
@@ -313,18 +313,18 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadDispatchData)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
// Get the BuildHlslSource() info (hierarchy and HLSL source)
// Get the HlslSource info (hierarchy, HLSL source and parsing options)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, string HlslSource)> hlslSourceInfo =
shaderInfoWithErrors
.Select(static (item, _) => (item.Hierarchy, item.HlslShaderSource.HlslSource));
// Generate the BuildHlslSource() methods
// Generate the HlslSource properties
context.RegisterSourceOutput(hlslSourceInfo, static (context, item) =>
{
PropertyDeclarationSyntax hlslStringProperty = BuildHlslSource.GetSyntax(item.Info.HlslSource, item.Info.Hierarchy.Hierarchy.Length);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Info.Hierarchy, hlslStringProperty, canUseSkipLocalsInit: false);
PropertyDeclarationSyntax hlslStringProperty = HlslSource.GetSyntax(item.HlslSource, item.Hierarchy.Hierarchy.Length);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, hlslStringProperty, canUseSkipLocalsInit: false);
context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.HlslSource.g.cs", compilationUnit.GetText(Encoding.UTF8));
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(HlslSource)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
// Get a filtered sequence to enable caching for the HLSL source info, before the shader compilation step