Add and generate ID2D1Shader.ShaderProfile

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-28 16:11:15 +02:00
1 親 000644f1c6
コミット 70b9aa9588
3ファイル変更
+39 -2

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

@@ -21,6 +21,28 @@ partial class ID2D1ShaderGenerator
/// <inheritdoc/>
partial class LoadBytecode
{
/// <summary>
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>ShaderProfile</c> property.
/// </summary>
/// <param name="bytecodeInfo">The input bytecode info.</param>
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>ShaderProfile</c> property.</returns>
public static PropertyDeclarationSyntax GetShaderProfileSyntax(EmbeddedBytecodeInfo bytecodeInfo)
{
// This code produces a method declaration as follows:
//
// readonly ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.__Internals.ID2D1Shader.ShaderProfile => <SHADER_PROFILE>;
return
PropertyDeclaration(IdentifierName("ComputeSharp.D2D1.D2D1ShaderProfile"), Identifier(nameof(ID2D1Shader.ShaderProfile)))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithExpressionBody(ArrowExpressionClause(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("global::ComputeSharp.D2D1.D2D1ShaderProfile"),
IdentifierName(bytecodeInfo.ShaderProfile.ToString()))))
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
}
/// <summary>
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>TryGetBytecode</c> method.
/// </summary>
+7 -2
ファイルの表示
@@ -363,10 +363,15 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
context.RegisterSourceOutput(embeddedBytecode, static (context, item) =>
{
MethodDeclarationSyntax loadBytecodeMethod = LoadBytecode.GetSyntax(item.BytecodeInfo, out Func<SyntaxNode, SourceText> fixup);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMember(item.Hierarchy, loadBytecodeMethod, skipLocalsInit: false);
SourceText text = fixup(compilationUnit);
CompilationUnitSyntax loadBytecodeCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, loadBytecodeMethod, skipLocalsInit: false);
SourceText text = fixup(loadBytecodeCompilationUnit);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadBytecode)}.g.cs", text);
PropertyDeclarationSyntax shaderProfileProperty = LoadBytecode.GetShaderProfileSyntax(item.BytecodeInfo);
CompilationUnitSyntax shaderProfileCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, shaderProfileProperty, skipLocalsInit: false);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.ShaderProfile.g.cs", shaderProfileCompilationUnit.GetText(Encoding.UTF8));
});
// Get the output buffer info (hierarchy and output buffers)
+10
ファイルの表示
@@ -127,6 +127,16 @@ public interface ID2D1Shader
[Obsolete("This method is not intended to be called directly by user code")]
string HlslSource { get; }
/// <summary>
/// Gets the shader profile for the current shader.
/// </summary>
/// <remarks>
/// This shader profile is either explicitly set by users, or the default one for D2D1 shaders.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
D2D1ShaderProfile ShaderProfile { get; }
/// <summary>
/// Loads the bytecode for the current shader.
/// </summary>