diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
index 30fa468d..fee46c11 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
@@ -23,6 +23,36 @@ partial class ID2D1ShaderGenerator
return GetEffectMetadataSyntax("EffectDisplayName", effectDisplayName);
}
+ ///
+ /// Creates a instance for the EffectDescription property.
+ ///
+ /// The input effect description value, if available.
+ /// The resulting instance for the EffectDescription property.
+ public static PropertyDeclarationSyntax GetEffectDescriptionSyntax(string? effectDescription)
+ {
+ return GetEffectMetadataSyntax("EffectDescription", effectDescription);
+ }
+
+ ///
+ /// Creates a instance for the EffectCategory property.
+ ///
+ /// The input effect category value, if available.
+ /// The resulting instance for the EffectCategory property.
+ public static PropertyDeclarationSyntax GetEffectCategorySyntax(string? effectCategory)
+ {
+ return GetEffectMetadataSyntax("EffectCategory", effectCategory);
+ }
+
+ ///
+ /// Creates a instance for the EffectAuthor property.
+ ///
+ /// The input effect author value, if available.
+ /// The resulting instance for the EffectAuthor property.
+ public static PropertyDeclarationSyntax GetEffectAuthorSyntax(string? effectAuthor)
+ {
+ return GetEffectMetadataSyntax("EffectAuthor", effectAuthor);
+ }
+
///
/// Creates a instance for a given metadata property.
///
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.cs
index 61efa038..9e574e31 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.cs
@@ -30,5 +30,65 @@ partial class ID2D1ShaderGenerator
return null;
}
+
+ ///
+ /// Extracts the effect description info for the current shader.
+ ///
+ /// The input object currently in use.
+ /// The for the shader type in use.
+ /// The resulting effect description, if available.
+ public static string? GetEffectDescriptionInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
+ {
+ if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
+ compilation,
+ structDeclarationSymbol,
+ "ComputeSharp.D2D1.D2DEffectDescriptionAttribute",
+ out string? effectDescription))
+ {
+ return effectDescription;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Extracts the effect category info for the current shader.
+ ///
+ /// The input object currently in use.
+ /// The for the shader type in use.
+ /// The resulting effect category, if available.
+ public static string? GetEffectCategoryInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
+ {
+ if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
+ compilation,
+ structDeclarationSymbol,
+ "ComputeSharp.D2D1.D2DEffectCategoryAttribute",
+ out string? effectCategory))
+ {
+ return effectCategory;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Extracts the effect author info for the current shader.
+ ///
+ /// The input object currently in use.
+ /// The for the shader type in use.
+ /// The resulting effect author, if available.
+ public static string? GetEffectAuthorInfo(Compilation compilation, INamedTypeSymbol structDeclarationSymbol)
+ {
+ if (D2D1EffectMetadataParser.TryGetEffectMetadataName(
+ compilation,
+ structDeclarationSymbol,
+ "ComputeSharp.D2D1.D2DEffectAuthorAttribute",
+ out string? effectAuthor))
+ {
+ return effectAuthor;
+ }
+
+ return null;
+ }
}
}
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
index 069525f1..d9f603b0 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.cs
@@ -50,8 +50,6 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
return default;
}
- using ImmutableArrayBuilder diagnostics = ImmutableArrayBuilder.Rent();
-
// EffectId info
ImmutableArray effectId = EffectId.GetInfo(context.SemanticModel.Compilation, typeSymbol);
@@ -62,6 +60,23 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
token.ThrowIfCancellationRequested();
+ // EffectDescription info
+ string? effectDescription = EffectMetadata.GetEffectDescriptionInfo(context.SemanticModel.Compilation, typeSymbol);
+
+ token.ThrowIfCancellationRequested();
+
+ // EffectCategory info
+ string? effectCategory = EffectMetadata.GetEffectCategoryInfo(context.SemanticModel.Compilation, typeSymbol);
+
+ token.ThrowIfCancellationRequested();
+
+ // EffectAuthor info
+ string? effectAuthor = EffectMetadata.GetEffectAuthorInfo(context.SemanticModel.Compilation, typeSymbol);
+
+ token.ThrowIfCancellationRequested();
+
+ using ImmutableArrayBuilder diagnostics = ImmutableArrayBuilder.Rent();
+
// LoadDispatchData() info
ImmutableArray fieldInfos = LoadDispatchData.GetInfo(
diagnostics,
@@ -127,6 +142,9 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
Hierarchy: HierarchyInfo.From(typeSymbol),
EffectId: new EffectIdInfo(effectId),
EffectDisplayName: effectDisplayName,
+ EffectDescription: effectDescription,
+ EffectCategory: effectCategory,
+ EffectAuthor: effectAuthor,
DispatchData: new DispatchDataInfo(fieldInfos, constantBufferSizeInBytes),
InputTypes: new InputTypesInfo(inputTypes),
ResourceTextureDescriptions: new ResourceTextureDescriptionsInfo(resourceTextureDescriptions),
@@ -148,6 +166,21 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
shaderInfoWithErrors
.Select(static (item, _) => item.Diagnostcs));
+ // Get the EffectId info (hierarchy and effect id info)
+ IncrementalValuesProvider<(HierarchyInfo Hierarchy, EffectIdInfo EffectId)> effectIdInfo =
+ shaderInfoWithErrors
+ .Select(static (item, _) => (item.Hierarchy, item.EffectId));
+
+ // Generate the EffectId properties
+ context.RegisterSourceOutput(effectIdInfo, static (context, item) =>
+ {
+ PropertyDeclarationSyntax effectDisplayNameProperty = EffectId.GetSyntax(item.EffectId, out Func fixup);
+ CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectDisplayNameProperty, canUseSkipLocalsInit: false);
+ SourceText text = fixup(compilationUnit);
+
+ context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(EffectId)}.g.cs", text);
+ });
+
// Get the EffectDisplayName info (hierarchy and effect display name)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, string? EffectDisplayName)> effectDisplayNameInfo =
shaderInfoWithErrors
@@ -162,19 +195,46 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.EffectDisplayName.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
- // Get the EffectId info (hierarchy and effect id info)
- IncrementalValuesProvider<(HierarchyInfo Hierarchy, EffectIdInfo EffectId)> effectIdInfo =
+ // Get the EffectDescription info (hierarchy and effect description)
+ IncrementalValuesProvider<(HierarchyInfo Hierarchy, string? EffectDescription)> effectDescriptionInfo =
shaderInfoWithErrors
- .Select(static (item, _) => (item.Hierarchy, item.EffectId));
+ .Select(static (item, _) => (item.Hierarchy, item.EffectDescription));
- // Generate the EffectId properties
- context.RegisterSourceOutput(effectIdInfo, static (context, item) =>
+ // Generate the EffectDescription properties
+ context.RegisterSourceOutput(effectDescriptionInfo, static (context, item) =>
{
- PropertyDeclarationSyntax effectDisplayNameProperty = EffectId.GetSyntax(item.EffectId, out Func fixup);
- CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectDisplayNameProperty, canUseSkipLocalsInit: false);
- SourceText text = fixup(compilationUnit);
+ PropertyDeclarationSyntax effectDescriptionProperty = EffectMetadata.GetEffectDescriptionSyntax(item.EffectDescription);
+ CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectDescriptionProperty, canUseSkipLocalsInit: false);
- context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(EffectId)}.g.cs", text);
+ context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.EffectDescription.g.cs", compilationUnit.GetText(Encoding.UTF8));
+ });
+
+ // Get the EffectCategory info (hierarchy and effect description)
+ IncrementalValuesProvider<(HierarchyInfo Hierarchy, string? EffectCategory)> effectCategoryInfo =
+ shaderInfoWithErrors
+ .Select(static (item, _) => (item.Hierarchy, item.EffectCategory));
+
+ // Generate the EffectCategory properties
+ context.RegisterSourceOutput(effectCategoryInfo, static (context, item) =>
+ {
+ PropertyDeclarationSyntax effectCategoryProperty = EffectMetadata.GetEffectCategorySyntax(item.EffectCategory);
+ CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectCategoryProperty, canUseSkipLocalsInit: false);
+
+ context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.EffectCategory.g.cs", compilationUnit.GetText(Encoding.UTF8));
+ });
+
+ // Get the EffectAuthor info (hierarchy and effect description)
+ IncrementalValuesProvider<(HierarchyInfo Hierarchy, string? EffectAuthor)> effectAuthorInfo =
+ shaderInfoWithErrors
+ .Select(static (item, _) => (item.Hierarchy, item.EffectAuthor));
+
+ // Generate the EffectAuthor properties
+ context.RegisterSourceOutput(effectAuthorInfo, static (context, item) =>
+ {
+ PropertyDeclarationSyntax effectCategoryProperty = EffectMetadata.GetEffectAuthorSyntax(item.EffectAuthor);
+ CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, effectCategoryProperty, canUseSkipLocalsInit: false);
+
+ context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.EffectAuthor.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
// Get the GetInputCount() info (hierarchy and input count)
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
index 36f9836d..5cd2c211 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/Models/D2D1ShaderInfo.cs
@@ -9,6 +9,9 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// The hierarchy info for the shader type.
/// The effect id info for the shader type.
/// The effect display name for the shader type, if available.
+/// The effect description for the shader type, if available.
+/// The effect category for the shader type, if available.
+/// The effect author for the shader type, if available.
/// The gathered shader dispatch data.
/// The gathered input types for the shader.
/// The gathered resource texture descriptions for the shader.
@@ -21,6 +24,9 @@ internal sealed record D2D1ShaderInfo(
HierarchyInfo Hierarchy,
EffectIdInfo EffectId,
string? EffectDisplayName,
+ string? EffectDescription,
+ string? EffectCategory,
+ string? EffectAuthor,
DispatchDataInfo DispatchData,
InputTypesInfo InputTypes,
ResourceTextureDescriptionsInfo ResourceTextureDescriptions,
diff --git a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
index 716c22d0..07f99fb6 100644
--- a/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
+++ b/src/ComputeSharp.D2D1/Interfaces/__Internals/ID2D1Shader.cs
@@ -27,6 +27,30 @@ public interface ID2D1Shader
///
string? EffectDisplayName { get; }
+ ///
+ /// Gets the description of the D2D effect using this shader, if specified.
+ ///
+ ///
+ /// This only applies to effects created from .
+ ///
+ string? EffectDescription { get; }
+
+ ///
+ /// Gets the category of the D2D effect using this shader, if specified.
+ ///
+ ///
+ /// This only applies to effects created from .
+ ///
+ string? EffectCategory { get; }
+
+ ///
+ /// Gets the author of the D2D effect using this shader, if specified.
+ ///
+ ///
+ /// This only applies to effects created from .
+ ///
+ string? EffectAuthor { get; }
+
///
/// Initializes the current shader from a buffer with the serialized dispatch data.
///