diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs index a7c73bf3..f36ce9ee 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs @@ -1,6 +1,5 @@ using System; using ComputeSharp.D2D1.__Internals; -using ComputeSharp.D2D1.SourceGenerators.Models; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; @@ -18,20 +17,20 @@ partial class ID2D1ShaderGenerator /// /// Creates a instance for the BufferPrecision property. /// - /// The input info for the shader output buffer. + /// The buffer precision for the resulting output buffer. /// The resulting instance for the BufferPrecision property. - public static PropertyDeclarationSyntax GetBufferPrecisionSyntax(OutputBufferInfo info) + public static PropertyDeclarationSyntax GetBufferPrecisionSyntax(D2D1BufferPrecision bufferPrecision) { ExpressionSyntax bufferPrecisionExpression; // Set the right expression if the buffer options are valid - if (Enum.IsDefined(typeof(D2D1BufferPrecision), info.BufferPrecision)) + if (Enum.IsDefined(typeof(D2D1BufferPrecision), bufferPrecision)) { bufferPrecisionExpression = MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("ComputeSharp.D2D1.D2D1BufferPrecision"), - IdentifierName(info.BufferPrecision.ToString())); + IdentifierName(bufferPrecision.ToString())); } else { @@ -53,20 +52,20 @@ partial class ID2D1ShaderGenerator /// /// Creates a instance for the ChannelDepth property. /// - /// The input info for the shader output buffer. + /// The channel depth for the resulting output buffer. /// The resulting instance for the ChannelDepth property. - public static PropertyDeclarationSyntax GetChannelDepthSyntax(OutputBufferInfo info) + public static PropertyDeclarationSyntax GetChannelDepthSyntax(D2D1ChannelDepth channelDepth) { ExpressionSyntax channelDepthExpression; // Set the right expression if the buffer options are valid - if (Enum.IsDefined(typeof(D2D1ChannelDepth), info.ChannelDepth)) + if (Enum.IsDefined(typeof(D2D1ChannelDepth), channelDepth)) { channelDepthExpression = MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, IdentifierName("ComputeSharp.D2D1.D2D1ChannelDepth"), - IdentifierName(info.ChannelDepth.ToString())); + IdentifierName(channelDepth.ToString())); } else { diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs index 54d845b1..479bcf69 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs @@ -154,7 +154,8 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator compileOptions, isLinkingSupported, HasErrors: diagnostics.Count > 0), - OutputBuffer: new OutputBufferInfo(bufferPrecision, channelDepth), + BufferPrecision: bufferPrecision, + ChannelDepth: channelDepth, InputDescriptions: new InputDescriptionsInfo(inputDescriptions), PixelOptions: pixelOptions, Diagnostcs: diagnostics.ToImmutable()); @@ -381,19 +382,19 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator }); // Get the output buffer info (hierarchy and output buffers) - IncrementalValuesProvider<(HierarchyInfo Hierarchy, OutputBufferInfo OutputBuffer)> outputBufferInfo = + IncrementalValuesProvider<(HierarchyInfo Hierarchy, D2D1BufferPrecision BufferPrecision, D2D1ChannelDepth ChannelDepth)> outputBufferInfo = shaderInfoWithErrors - .Select(static (item, _) => (item.Hierarchy, item.OutputBuffer)); + .Select(static (item, _) => (item.Hierarchy, item.BufferPrecision, item.ChannelDepth)); // Generate the output buffer properties context.RegisterSourceOutput(outputBufferInfo, static (context, item) => { - PropertyDeclarationSyntax bufferPrecisionProperty = OutputBuffer.GetBufferPrecisionSyntax(item.OutputBuffer); + PropertyDeclarationSyntax bufferPrecisionProperty = OutputBuffer.GetBufferPrecisionSyntax(item.BufferPrecision); CompilationUnitSyntax bufferPrecisionCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, bufferPrecisionProperty, skipLocalsInit: false); context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.BufferPrecision.g.cs", bufferPrecisionCompilationUnit.GetText(Encoding.UTF8)); - PropertyDeclarationSyntax channelDepthProperty = OutputBuffer.GetChannelDepthSyntax(item.OutputBuffer); + PropertyDeclarationSyntax channelDepthProperty = OutputBuffer.GetChannelDepthSyntax(item.ChannelDepth); CompilationUnitSyntax channelDepthCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, channelDepthProperty, skipLocalsInit: false); context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.ChannelDepth.g.cs", channelDepthCompilationUnit.GetText(Encoding.UTF8)); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs index e877eb6a..f0374179 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs @@ -17,7 +17,8 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models; /// The gathered input types for the shader. /// The gathered resource texture descriptions for the shader. /// The processed HLSL source for the shader. -/// The output buffer info for the shader. +/// The buffer precision for the resulting output buffer. +/// The channel depth for the resulting output buffer. /// The gathered input descriptions for the shader. /// The pixel options used by the shader. /// The discovered diagnostics, if any. @@ -33,7 +34,8 @@ internal sealed record D2D1ShaderInfo( EquatableArray InputTypes, EquatableArray ResourceTextureDescriptions, HlslShaderSourceInfo HlslShaderSource, - OutputBufferInfo OutputBuffer, + D2D1BufferPrecision BufferPrecision, + D2D1ChannelDepth ChannelDepth, InputDescriptionsInfo InputDescriptions, D2D1PixelOptions PixelOptions, EquatableArray Diagnostcs); \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/OutputBufferInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/OutputBufferInfo.cs deleted file mode 100644 index 98f3b85e..00000000 --- a/src/ComputeSharp.D2D1.SourceGenerators/Models/OutputBufferInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ComputeSharp.D2D1.SourceGenerators.Models; - -/// -/// A model representing the output buffer info for a shader. -/// -/// The buffer precision for the resulting output buffer. -/// The channel depth for the resulting output buffer. -internal sealed record OutputBufferInfo(D2D1BufferPrecision BufferPrecision, D2D1ChannelDepth ChannelDepth); \ No newline at end of file