Skip to content

Commit

Permalink
Remove LoadInputDescriptions<TLoader> API
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Sep 23, 2023
1 parent 4a4bc33 commit 0302442
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<Compile Include="..\ComputeSharp.D2D1\Interfaces\ID2D1PixelShader.cs" Link="ComputeSharp.D2D1\Interfaces\ID2D1PixelShader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Interfaces\__Internals\ID2D1BytecodeLoader.cs" Link="ComputeSharp.D2D1\Interfaces\__Internals\ID2D1BytecodeLoader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Interfaces\__Internals\ID2D1DispatchDataLoader.cs" Link="ComputeSharp.D2D1\Interfaces\__Internals\ID2D1DispatchDataLoader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Interfaces\__Internals\ID2D1InputDescriptionsLoader.cs" Link="ComputeSharp.D2D1\Interfaces\__Internals\ID2D1InputDescriptionsLoader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Interfaces\__Internals\ID2D1ResourceTextureDescriptionsLoader.cs" Link="ComputeSharp.D2D1\Interfaces\__Internals\ID2D1ResourceTextureDescriptionsLoader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Interfaces\__Internals\ID2D1Shader.cs" Link="ComputeSharp.D2D1\Interfaces\__Internals\ID2D1Shader.cs" />
<Compile Include="..\ComputeSharp.D2D1\Intrinsics\D2D.cs" Link="ComputeSharp.D2D1\Intrinsics\D2D.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
/// <inheritoc/>
private static partial class LoadInputDescriptions
private static partial class InputDescriptions
{
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>InputDescriptions</c> property.
Expand All @@ -39,7 +39,7 @@ public static PropertyDeclarationSyntax GetSyntax(InputDescriptionsInfo inputDes
memoryExpression = MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("Data"),
IdentifierName("InputDescriptions"));
IdentifierName(nameof(InputDescriptions)));

additionalTypes = new[] { GetArrayDeclaration(inputDescriptionsInfo) };
}
Expand All @@ -54,7 +54,7 @@ public static PropertyDeclarationSyntax GetSyntax(InputDescriptionsInfo inputDes
PropertyDeclaration(
GenericName(Identifier("global::System.ReadOnlyMemory"))
.AddTypeArgumentListArguments(IdentifierName("global::ComputeSharp.D2D1.Interop.D2D1InputDescription")),
Identifier("InputDescriptions"))
Identifier(nameof(InputDescriptions)))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithExpressionBody(ArrowExpressionClause(memoryExpression))
Expand Down Expand Up @@ -118,7 +118,7 @@ private static TypeDeclarationSyntax GetArrayDeclaration(InputDescriptionsInfo i
ArrayType(IdentifierName("global::ComputeSharp.D2D1.Interop.D2D1InputDescription"))
.AddRankSpecifiers(ArrayRankSpecifier(SingletonSeparatedList<ExpressionSyntax>(OmittedArraySizeExpression()))))
.AddVariables(
VariableDeclarator(Identifier("InputDescriptions"))
VariableDeclarator(Identifier(nameof(InputDescriptions)))
.WithInitializer(EqualsValueClause(
InitializerExpression(SyntaxKind.ArrayInitializerExpression)
.AddExpressions(inputDescriptionExpressions.ToArray())))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace ComputeSharp.D2D1.SourceGenerators;
partial class ID2D1ShaderGenerator
{
/// <summary>
/// A helper with all logic to generate the <c>LoadInputDescriptions</c> method.
/// A helper with all logic to generate the <c>InputDescriptions</c> property.
/// </summary>
private static partial class LoadInputDescriptions
private static partial class InputDescriptions
{
/// <summary>
/// Extracts the input descriptions for the current shader.
Expand Down
12 changes: 6 additions & 6 deletions src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
token.ThrowIfCancellationRequested();
// Get the info for LoadInputDescriptions()
LoadInputDescriptions.GetInfo(
// Get the info for InputDescriptions
InputDescriptions.GetInfo(
diagnostics,
typeSymbol,
out ImmutableArray<InputDescription> inputDescriptions);
Expand Down Expand Up @@ -299,19 +299,19 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(GetOutputBuffer)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});

// Get the LoadInputDescriptions() info (hierarchy and input descriptions)
// Get the InputDescriptions info (hierarchy and input descriptions)
IncrementalValuesProvider<((HierarchyInfo Hierarchy, InputDescriptionsInfo InputDescriptions) Info, bool CanUseSkipLocalsInit)> inputDescriptionsInfo =
shaderInfoWithErrors
.Select(static (item, _) => (item.Hierarchy, item.InputDescriptions))
.Combine(canUseSkipLocalsInit);

// Generate the LoadInputDescriptions() methods
// Generate the InputDescriptions properties
context.RegisterSourceOutput(inputDescriptionsInfo, static (context, item) =>
{
PropertyDeclarationSyntax inputDescriptionsProperty = LoadInputDescriptions.GetSyntax(item.Info.InputDescriptions, out TypeDeclarationSyntax[] additionalTypes);
PropertyDeclarationSyntax inputDescriptionsProperty = InputDescriptions.GetSyntax(item.Info.InputDescriptions, out TypeDeclarationSyntax[] additionalTypes);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Info.Hierarchy, inputDescriptionsProperty, item.CanUseSkipLocalsInit, additionalMemberDeclarations: additionalTypes);
context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadInputDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
context.AddSource($"{item.Info.Hierarchy.FullyQualifiedMetadataName}.{nameof(InputDescriptions)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});

// Get the GetPixelOptions() info (hierarchy and pixel options)
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ public interface ID2D1Shader
[Obsolete("This method is not intended to be used directly by user code")]
ReadOnlyMemory<D2D1InputDescription> InputDescriptions { get; }

/// <summary>
/// Loads the input descriptions for the shader, if any.
/// </summary>
/// <typeparam name="TLoader">The type of input descriptions loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the input descriptions.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
void LoadInputDescriptions<TLoader>(ref TLoader loader)
where TLoader : struct, ID2D1InputDescriptionsLoader;

/// <summary>
/// Loads the resource texture descriptions for the shader, if any.
/// </summary>
Expand Down
6 changes: 1 addition & 5 deletions src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,9 @@ public static ReadOnlyMemory<D2D1PixelShaderInputType> GetInputTypes<T>()
public static ReadOnlyMemory<D2D1InputDescription> GetInputDescriptions<T>()
where T : unmanaged, ID2D1PixelShader
{
D2D1ByteArrayInputDescriptionsLoader inputDescriptionsLoader = default;

Unsafe.SkipInit(out T shader);

shader.LoadInputDescriptions(ref inputDescriptionsLoader);

return inputDescriptionsLoader.GetResultingInputDescriptions();
return shader.InputDescriptions;
}

/// <summary>
Expand Down

This file was deleted.

0 comments on commit 0302442

Please sign in to comment.