Rename D2D1 generator file names and generated name
このコミットが含まれているのは:
1 親
80221ce0cd
コミット
ec77fb7e6f
26ファイル変更
+62
-86
検索条件に一致するファイルはありません
+2
-2
@@ -6,7 +6,7 @@ using ComputeSharp.SourceGeneration.Mappings;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class CreateFromConstantBuffer
|
||||
@@ -21,7 +21,7 @@ partial class ID2D1ShaderGenerator
|
||||
string typeName = info.Hierarchy.Hierarchy[0].QualifiedName;
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]");
|
||||
writer.WriteLine($"readonly unsafe {typeName} global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.CreateFromConstantBuffer(global::System.ReadOnlySpan<byte> data)");
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class EffectId
|
||||
@@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ref readonly global::System.Guid global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.EffectId");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
+1
-1
@@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>EffectId</c> property.
|
||||
+2
-2
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class EffectMetadata
|
||||
@@ -60,7 +60,7 @@ partial class ID2D1ShaderGenerator
|
||||
private static void WriteEffectMetadataSyntax(string qualifiedName, string propertyName, string? metadataValue, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly string? global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{qualifiedName}>.{propertyName} => ");
|
||||
|
||||
// Append null or the metadata value as a string literal
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the effect metadata properties.
|
||||
+5
-5
@@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class HlslBytecode
|
||||
@@ -20,7 +20,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteShaderProfileSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.{info.HlslInfoKey.EffectiveShaderProfile};");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ partial class ID2D1ShaderGenerator
|
||||
.Aggregate("", static (left, right) => left.Length > 0 ? $"{left} | {right}" : right);
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.CompileOptions => {compileOptionsExpression};");
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteHlslBytecodeSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<byte> global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslBytecode => ");
|
||||
|
||||
// If there is no bytecode, just return a default expression.
|
||||
@@ -98,7 +98,7 @@ partial class ID2D1ShaderGenerator
|
||||
writer.WriteLine($$"""/// <summary>""");
|
||||
writer.WriteLine($$"""/// <see cref="MemoryManager{T}"/> implementation to get the HLSL bytecode.""");
|
||||
writer.WriteLine($$"""/// </summary>""");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator), useFullyQualifiedTypeNames: false);
|
||||
writer.WriteGeneratedAttributes(GeneratorName, useFullyQualifiedTypeNames: false);
|
||||
writer.WriteLine($$"""file sealed class HlslBytecodeMemoryManager : MemoryManager<byte>""");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
+1
-1
@@ -18,7 +18,7 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the HLSL bytecode properties.
|
||||
+2
-2
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class HlslSource
|
||||
@@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly string global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslSource =>");
|
||||
writer.IncreaseIndent();
|
||||
writer.WriteLine("\"\"\"");
|
||||
+1
-1
@@ -17,7 +17,7 @@ using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>HlslSource</c> property.
|
||||
+3
-3
@@ -7,7 +7,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritoc/>
|
||||
private static partial class InputDescriptions
|
||||
@@ -20,7 +20,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<global::ComputeSharp.D2D1.Interop.D2D1InputDescription> global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputDescriptions => ");
|
||||
|
||||
// If there are no input descriptions, just return a default expression.
|
||||
@@ -66,7 +66,7 @@ partial class ID2D1ShaderGenerator
|
||||
writer.WriteLine($$"""/// <summary>""");
|
||||
writer.WriteLine($$"""/// A container type for additional data needed by the shader.""");
|
||||
writer.WriteLine($$"""/// </summary>""");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator), useFullyQualifiedTypeNames: false);
|
||||
writer.WriteGeneratedAttributes(GeneratorName, useFullyQualifiedTypeNames: false);
|
||||
writer.WriteLine($$"""file static class Data""");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
+1
-1
@@ -10,7 +10,7 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>InputDescriptions</c> property.
|
||||
+3
-3
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class InputTypes
|
||||
@@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<global::ComputeSharp.D2D1.Interop.D2D1PixelShaderInputType> global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputTypes => ");
|
||||
|
||||
// If there are no inputs, simply return a default expression. Otherwise, create
|
||||
@@ -65,7 +65,7 @@ partial class ID2D1ShaderGenerator
|
||||
writer.WriteLine($$"""/// <summary>""");
|
||||
writer.WriteLine($$"""/// A <see cref="MemoryManager{T}"/> implementation to get the input types.""");
|
||||
writer.WriteLine($$"""/// </summary>""");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator), useFullyQualifiedTypeNames: false);
|
||||
writer.WriteGeneratedAttributes(GeneratorName, useFullyQualifiedTypeNames: false);
|
||||
writer.WriteLine($$"""file sealed class InputTypesMemoryManager : MemoryManager<D2D1PixelShaderInputType>""");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
+1
-1
@@ -9,7 +9,7 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>InputTypes</c> properties.
|
||||
+3
-3
@@ -6,7 +6,7 @@ using ComputeSharp.SourceGeneration.Mappings;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class LoadConstantBuffer
|
||||
@@ -21,7 +21,7 @@ partial class ID2D1ShaderGenerator
|
||||
string typeName = info.Hierarchy.Hierarchy[0].QualifiedName;
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]");
|
||||
writer.WriteLine($"readonly unsafe void global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{typeName}>.LoadConstantBuffer<TLoader>(in {typeName} shader, ref TLoader loader)");
|
||||
|
||||
@@ -105,7 +105,7 @@ partial class ID2D1ShaderGenerator
|
||||
writer.WriteLine($$"""/// <summary>""");
|
||||
writer.WriteLine($$"""/// A type representing the constant buffer native layout for <see cref="{{fullyQualifiedTypeName}}"/>.""");
|
||||
writer.WriteLine($$"""/// </summary>""");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator), useFullyQualifiedTypeNames: false);
|
||||
writer.WriteGeneratedAttributes(GeneratorName, useFullyQualifiedTypeNames: false);
|
||||
writer.WriteLine($$"""[StructLayout(LayoutKind.Explicit, Size = {{info.ConstantBufferSizeInBytes}})]""");
|
||||
writer.WriteLine($$"""file struct ConstantBuffer""");
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>LoadConstantBuffer</c> method.
|
||||
+4
-4
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the available numeric properties.
|
||||
@@ -20,7 +20,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteConstantBufferSizeSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ConstantBufferSize => {info.ConstantBufferSizeInBytes};");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteInputCountSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.InputCount => {info.InputTypes.Length};");
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteResourceTextureCountSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureCount => {info.ResourceTextureDescriptions.Length};");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,7 +6,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class OutputBuffer
|
||||
@@ -27,7 +27,7 @@ partial class ID2D1ShaderGenerator
|
||||
};
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.BufferPrecision => {bufferPrecisionExpression};");
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ partial class ID2D1ShaderGenerator
|
||||
};
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ChannelDepth => {channelDepthExpression};");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the output buffer properties.
|
||||
+2
-2
@@ -5,7 +5,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class PixelOptions
|
||||
@@ -25,7 +25,7 @@ partial class ID2D1ShaderGenerator
|
||||
};
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.PixelOptions => {pixelOptionsExpression};");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>PixelOptions</c> property.
|
||||
+2
-2
@@ -7,7 +7,7 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritoc/>
|
||||
private static partial class ResourceTextureDescriptions
|
||||
@@ -20,7 +20,7 @@ partial class ID2D1ShaderGenerator
|
||||
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<global::ComputeSharp.D2D1.Interop.D2D1ResourceTextureDescription> global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceTextureDescriptions => ");
|
||||
|
||||
// If there are no resource texture descriptions, just return a default expression.
|
||||
+1
-1
@@ -11,7 +11,7 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
partial class D2DPixelShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>ResourceTextureDescriptions</c> property.
|
||||
+9
-4
@@ -10,11 +10,16 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <summary>
|
||||
/// A source generator creating data loaders for the <see cref="ID2D1PixelShader"/> type.
|
||||
/// A source generator creating pixel shader descriptors for annotated D2D1 pixel shader types.
|
||||
/// </summary>
|
||||
[Generator(LanguageNames.CSharp)]
|
||||
public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of generator to include in the generated code.
|
||||
/// </summary>
|
||||
private const string GeneratorName = "ComputeSharp.D2D1.D2DPixelShaderDescriptorGenerator";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
@@ -41,7 +46,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
StructDeclarationSyntax typeDeclaration = (StructDeclarationSyntax)context.TargetNode;
|
||||
|
||||
// Check that the shader implements the ID2D1PixelShader interface
|
||||
if (!IsD2D1PixelShaderType(typeSymbol, context.SemanticModel.Compilation))
|
||||
if (!typeSymbol.HasInterfaceWithType(context.SemanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader")!))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
@@ -151,7 +156,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
effectiveCompileOptions,
|
||||
hasErrors);
|
||||
|
||||
// TODO: cache this across transform runs
|
||||
// Get the existing compiled shader, or compile the processed HLSL code
|
||||
HlslBytecodeInfo hlslInfo = HlslBytecode.GetInfo(ref hlslInfoKey, token);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
+2
-4
@@ -52,15 +52,13 @@ public sealed class D2D1ResourceTextureUninitializedFieldDiagnosticSuppressor :
|
||||
HlslKnownTypes.IsResourceTextureType(fieldSymbol.Type.GetFullyQualifiedMetadataName()))
|
||||
{
|
||||
// Get the ID2D1PixelShader interface symbol to the check the containing type of the field
|
||||
INamedTypeSymbol? pixelShaderInterfaceSymbol = semanticModel.Compilation.GetTypeByMetadataName(typeof(ID2D1PixelShader).FullName)!;
|
||||
|
||||
if (pixelShaderInterfaceSymbol is null)
|
||||
if (semanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader") is not { } d2D1PixelShaderSymbol)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Also check if the containing type is in fact a D2D1 pixel shader type
|
||||
if (ID2D1ShaderGenerator.IsD2D1PixelShaderType(structSymbol, semanticModel.Compilation))
|
||||
if (structSymbol.HasInterfaceWithType(d2D1PixelShaderSymbol))
|
||||
{
|
||||
context.ReportSuppression(Suppression.Create(UninitializedD2D1ResourceTextureField, diagnostic));
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ID2D1ShaderGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the shader type for a given shader, if any.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The input <see cref="INamedTypeSymbol"/> instance to check.</param>
|
||||
/// <param name="compilation">The <see cref="Compilation"/> instance currently in use.</param>
|
||||
/// <returns>Whether or not <paramref name="typeSymbol"/> is a D2D1 interface type.</returns>
|
||||
public static bool IsD2D1PixelShaderType(INamedTypeSymbol typeSymbol, Compilation compilation)
|
||||
{
|
||||
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
|
||||
{
|
||||
if (interfaceSymbol.Name == nameof(ID2D1PixelShader))
|
||||
{
|
||||
INamedTypeSymbol d2D1PixelShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader")!;
|
||||
|
||||
if (SymbolEqualityComparer.Default.Equals(interfaceSymbol, d2D1PixelShaderSymbol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,19 +17,23 @@ internal static class IndentedTextWriterExtensions
|
||||
/// </code>
|
||||
/// </summary>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
/// <param name="generatorType">The type of the running generator.</param>
|
||||
/// <param name="generatorName">The name of the generator.</param>
|
||||
/// <param name="useFullyQualifiedTypeNames">Whether to use fully qualified type names or not.</param>
|
||||
public static void WriteGeneratedAttributes(this IndentedTextWriter writer, Type generatorType, bool useFullyQualifiedTypeNames = true)
|
||||
public static void WriteGeneratedAttributes(this IndentedTextWriter writer, string generatorName, bool useFullyQualifiedTypeNames = true)
|
||||
{
|
||||
// We can use this class to get the assembly, as all files for generators are just included
|
||||
// via shared projects. As such, the assembly will be the same as the generator type itself.
|
||||
Version assemblyVersion = typeof(IndentedTextWriterExtensions).Assembly.GetName().Version;
|
||||
|
||||
if (useFullyQualifiedTypeNames)
|
||||
{
|
||||
writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
|
||||
writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorName}}", "{{assemblyVersion}}")]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($$"""[GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
|
||||
writer.WriteLine($$"""[GeneratedCode("{{generatorName}}", "{{assemblyVersion}}")]""");
|
||||
writer.WriteLine($$"""[DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする