Remove ID2D1Shader.GetOutputBuffer method and generation

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-28 00:12:18 +02:00
1 親 a71c4db7dd
コミット ca77bab1f2
5ファイル変更
+11 -63

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

@@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
/// <inheritdoc/>
partial class GetOutputBuffer
partial class OutputBuffer
{
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>BufferPrecision</c> property.
@@ -84,39 +84,5 @@ partial class ID2D1ShaderGenerator
.WithExpressionBody(ArrowExpressionClause(channelDepthExpression))
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
}
/// <summary>
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>GetOutputBuffer</c> method.
/// </summary>
/// <param name="info">The input info for the shader output buffer.</param>
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>GetOutputBuffer</c> method.</returns>
public static MethodDeclarationSyntax GetSyntax(OutputBufferInfo info)
{
// This code produces a method declaration as follows:
//
// readonly void global::ComputeSharp.D2D1.__Internals.ID2D1Shader.GetOutputBuffer(out uint precision, out uint depth)
// {
// precision = <BUFFER_PRECISION>;
// depth = <CHANNEL_DEPTH>;
// }
return
MethodDeclaration(PredefinedType(Token(SyntaxKind.VoidKeyword)), Identifier(nameof(GetOutputBuffer)))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddParameterListParameters(
Parameter(Identifier("precision")).AddModifiers(Token(SyntaxKind.OutKeyword)).WithType(PredefinedType(Token(SyntaxKind.UIntKeyword))),
Parameter(Identifier("depth")).AddModifiers(Token(SyntaxKind.OutKeyword)).WithType(PredefinedType(Token(SyntaxKind.UIntKeyword))))
.WithBody(Block(
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("precision"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)info.BufferPrecision)))),
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("depth"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal((int)info.ChannelDepth))))));
}
}
}
@@ -7,9 +7,9 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
/// <summary>
/// A helper with all logic to generate the <c>GetOutputBuffer</c> method.
/// A helper with all logic to generate the output buffer properties.
/// </summary>
private static partial class GetOutputBuffer
private static partial class OutputBuffer
{
/// <summary>
/// Extracts the output buffer info for the current shader.
+6 -11
ファイルの表示
@@ -126,8 +126,8 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
token.ThrowIfCancellationRequested();
// Get the info for GetOutputBuffer()
GetOutputBuffer.GetInfo(typeSymbol, out D2D1BufferPrecision bufferPrecision, out D2D1ChannelDepth channelDepth);
// Get the info for the output buffer properties
OutputBuffer.GetInfo(typeSymbol, out D2D1BufferPrecision bufferPrecision, out D2D1ChannelDepth channelDepth);
token.ThrowIfCancellationRequested();
@@ -386,25 +386,20 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadBytecode)}.g.cs", text);
});
// Get the GetOutputBuffer() info (hierarchy and output buffers)
// Get the output buffer info (hierarchy and output buffers)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, OutputBufferInfo OutputBuffer)> outputBufferInfo =
shaderInfoWithErrors
.Select(static (item, _) => (item.Hierarchy, item.OutputBuffer));
// Generate the GetOutputBuffer() methods
// Generate the output buffer properties
context.RegisterSourceOutput(outputBufferInfo, static (context, item) =>
{
MethodDeclarationSyntax getOutputBufferMethod = GetOutputBuffer.GetSyntax(item.OutputBuffer);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, getOutputBufferMethod, canUseSkipLocalsInit: false);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetOutputBuffer)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
PropertyDeclarationSyntax bufferPrecisionProperty = GetOutputBuffer.GetBufferPrecisionSyntax(item.OutputBuffer);
PropertyDeclarationSyntax bufferPrecisionProperty = OutputBuffer.GetBufferPrecisionSyntax(item.OutputBuffer);
CompilationUnitSyntax bufferPrecisionCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, bufferPrecisionProperty, canUseSkipLocalsInit: false);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.BufferPrecision.g.cs", bufferPrecisionCompilationUnit.GetText(Encoding.UTF8));
PropertyDeclarationSyntax channelDepthProperty = GetOutputBuffer.GetChannelDepthSyntax(item.OutputBuffer);
PropertyDeclarationSyntax channelDepthProperty = OutputBuffer.GetChannelDepthSyntax(item.OutputBuffer);
CompilationUnitSyntax channelDepthCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, channelDepthProperty, canUseSkipLocalsInit: false);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.ChannelDepth.g.cs", channelDepthCompilationUnit.GetText(Encoding.UTF8));
-9
ファイルの表示
@@ -111,15 +111,6 @@ public interface ID2D1Shader
[Obsolete("This method is not intended to be used directly by user code")]
D2D1ChannelDepth ChannelDepth { get; }
/// <summary>
/// Gets the output buffer precision and depth for the shader.
/// </summary>
/// <param name="precision">The output buffer precision.</param>
/// <param name="depth">The output buffer channel depth.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
void GetOutputBuffer(out uint precision, out uint depth);
/// <summary>
/// Loads the dispatch data for the shader.
/// </summary>
+2 -6
ファイルの表示
@@ -307,9 +307,7 @@ public static class D2D1PixelShader
{
Unsafe.SkipInit(out T shader);
shader.GetOutputBuffer(out uint precision, out _);
return (D2D1BufferPrecision)precision;
return shader.BufferPrecision;
}
/// <summary>
@@ -322,9 +320,7 @@ public static class D2D1PixelShader
{
Unsafe.SkipInit(out T shader);
shader.GetOutputBuffer(out _, out uint depth);
return (D2D1ChannelDepth)depth;
return shader.ChannelDepth;
}
/// <summary>