From 8d129d3d30aef335a1a9aa7b8f5e2dc1136df481 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 28 Sep 2023 20:37:00 +0200 Subject: [PATCH] Remove ResourceTextureDescriptionsInfo model --- ...teResourceTextureDescriptionsProperty.Syntax.cs | 14 +++++++------- .../ID2D1ShaderGenerator.cs | 4 ++-- .../Models/D2D1ShaderInfo.cs | 2 +- .../Models/ResourceTextureDescriptionsInfo.cs | 9 --------- 4 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 src/ComputeSharp.D2D1.SourceGenerators/Models/ResourceTextureDescriptionsInfo.cs diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs index 9748945f..f41735b2 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs @@ -20,16 +20,16 @@ partial class ID2D1ShaderGenerator /// /// Creates a instance for the ResourceTextureDescriptions property. /// - /// The resource texture descriptions info gathered for the current shader. + /// The resource texture descriptions info gathered for the current shader. /// Any additional instances needed by the generated code, if needed. /// The resulting instance for the ResourceTextureDescriptions property. - public static PropertyDeclarationSyntax GetSyntax(ResourceTextureDescriptionsInfo resourceTextureDescriptionsInfo, out TypeDeclarationSyntax[] additionalTypes) + public static PropertyDeclarationSyntax GetSyntax(EquatableArray resourceTextureDescriptions, out TypeDeclarationSyntax[] additionalTypes) { ExpressionSyntax memoryExpression; // If there are no resource texture descriptions, just return a default expression. // Otherwise, declare the shared array and return it from the property. - if (resourceTextureDescriptionsInfo.ResourceTextureDescriptions.Length == 0) + if (resourceTextureDescriptions.Length == 0) { memoryExpression = LiteralExpression(SyntaxKind.DefaultLiteralExpression, Token(SyntaxKind.DefaultKeyword)); additionalTypes = Array.Empty(); @@ -41,7 +41,7 @@ partial class ID2D1ShaderGenerator IdentifierName("Data"), IdentifierName(nameof(ResourceTextureDescriptions))); - additionalTypes = new[] { GetArrayDeclaration(resourceTextureDescriptionsInfo) }; + additionalTypes = new[] { GetArrayDeclaration(resourceTextureDescriptions) }; } // This code produces a method declaration as follows: @@ -61,13 +61,13 @@ partial class ID2D1ShaderGenerator /// /// Gets the array declaration for the given resource texture descriptions. /// - /// The resource texture descriptions info gathered for the current shader. + /// The resource texture descriptions info gathered for the current shader. /// The array declaration for the given resource texture descriptions. - private static TypeDeclarationSyntax GetArrayDeclaration(ResourceTextureDescriptionsInfo resourceTextureDescriptionsInfo) + private static TypeDeclarationSyntax GetArrayDeclaration(EquatableArray resourceTextureDescriptions) { using ImmutableArrayBuilder resourceTextureDescriptionExpressions = ImmutableArrayBuilder.Rent(); - foreach (ResourceTextureDescription resourceTextureDescription in resourceTextureDescriptionsInfo.ResourceTextureDescriptions) + foreach (ResourceTextureDescription resourceTextureDescription in resourceTextureDescriptions) { // Create the description expression: // diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs index 7c9e0a7c..54d845b1 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs @@ -147,7 +147,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator ConstantBufferSizeInBytes: constantBufferSizeInBytes, Fields: fieldInfos, InputTypes: inputTypes, - ResourceTextureDescriptions: new ResourceTextureDescriptionsInfo(resourceTextureDescriptions), + ResourceTextureDescriptions: resourceTextureDescriptions, HlslShaderSource: new HlslShaderSourceInfo( hlslSource, shaderProfile, @@ -266,7 +266,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator }); // Get the ResourceTextureDescriptions info (hierarchy and resource texture descriptions) - IncrementalValuesProvider<(HierarchyInfo Hierarchy, ResourceTextureDescriptionsInfo ResourceTextureDescriptions)> resourceTextureDescriptionsInfo = + IncrementalValuesProvider<(HierarchyInfo Hierarchy, EquatableArray ResourceTextureDescriptions)> resourceTextureDescriptionsInfo = shaderInfoWithErrors .Select(static (item, _) => (item.Hierarchy, item.ResourceTextureDescriptions)); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs index 0d6f3211..e877eb6a 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs @@ -31,7 +31,7 @@ internal sealed record D2D1ShaderInfo( int ConstantBufferSizeInBytes, EquatableArray Fields, EquatableArray InputTypes, - ResourceTextureDescriptionsInfo ResourceTextureDescriptions, + EquatableArray ResourceTextureDescriptions, HlslShaderSourceInfo HlslShaderSource, OutputBufferInfo OutputBuffer, InputDescriptionsInfo InputDescriptions, diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/ResourceTextureDescriptionsInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/ResourceTextureDescriptionsInfo.cs deleted file mode 100644 index 4661508c..00000000 --- a/src/ComputeSharp.D2D1.SourceGenerators/Models/ResourceTextureDescriptionsInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -using ComputeSharp.SourceGeneration.Helpers; - -namespace ComputeSharp.D2D1.SourceGenerators.Models; - -/// -/// A model representing gathered resource texture descriptions for a shader. -/// -/// The resource textures for the current shader. -internal sealed record ResourceTextureDescriptionsInfo(EquatableArray ResourceTextureDescriptions); \ No newline at end of file