Remove OutputBufferInfo model

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-28 20:40:02 +02:00
1 親 8d129d3d30
コミット 96a81ec009
4ファイル変更
+18 -24

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

@@ -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
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>BufferPrecision</c> property.
/// </summary>
/// <param name="info">The input info for the shader output buffer.</param>
/// <param name="bufferPrecision">The buffer precision for the resulting output buffer.</param>
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>BufferPrecision</c> property.</returns>
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
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>ChannelDepth</c> property.
/// </summary>
/// <param name="info">The input info for the shader output buffer.</param>
/// <param name="channelDepth">The channel depth for the resulting output buffer.</param>
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>ChannelDepth</c> property.</returns>
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
{
+6 -5
ファイルの表示
@@ -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));
+4 -2
ファイルの表示
@@ -17,7 +17,8 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <param name="InputTypes">The gathered input types for the shader.</param>
/// <param name="ResourceTextureDescriptions">The gathered resource texture descriptions for the shader.</param>
/// <param name="HlslShaderSource">The processed HLSL source for the shader.</param>
/// <param name="OutputBuffer">The output buffer info for the shader.</param>
/// <param name="BufferPrecision">The buffer precision for the resulting output buffer.</param>
/// <param name="ChannelDepth">The channel depth for the resulting output buffer.</param>
/// <param name="InputDescriptions">The gathered input descriptions for the shader.</param>
/// <param name="PixelOptions">The pixel options used by the shader.</param>
/// <param name="Diagnostcs">The discovered diagnostics, if any.</param>
@@ -33,7 +34,8 @@ internal sealed record D2D1ShaderInfo(
EquatableArray<uint> InputTypes,
EquatableArray<ResourceTextureDescription> ResourceTextureDescriptions,
HlslShaderSourceInfo HlslShaderSource,
OutputBufferInfo OutputBuffer,
D2D1BufferPrecision BufferPrecision,
D2D1ChannelDepth ChannelDepth,
InputDescriptionsInfo InputDescriptions,
D2D1PixelOptions PixelOptions,
EquatableArray<DiagnosticInfo> Diagnostcs);
-8
ファイルの表示
@@ -1,8 +0,0 @@
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A model representing the output buffer info for a shader.
/// </summary>
/// <param name="BufferPrecision">The buffer precision for the resulting output buffer.</param>
/// <param name="ChannelDepth">The channel depth for the resulting output buffer.</param>
internal sealed record OutputBufferInfo(D2D1BufferPrecision BufferPrecision, D2D1ChannelDepth ChannelDepth);