Add and generate ID2D1Shader.CompileOptions
このコミットが含まれているのは:
1 親
70b9aa9588
コミット
423c87cab8
3ファイル変更
+43
-1
検索条件に一致するファイルはありません
+28
-1
@@ -39,7 +39,34 @@ partial class ID2D1ShaderGenerator
|
||||
MemberAccessExpression(
|
||||
SyntaxKind.SimpleMemberAccessExpression,
|
||||
IdentifierName("global::ComputeSharp.D2D1.D2D1ShaderProfile"),
|
||||
IdentifierName(bytecodeInfo.ShaderProfile.ToString()))))
|
||||
IdentifierName(bytecodeInfo.ShaderProfile.ToString(CultureInfo.InvariantCulture)))))
|
||||
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="PropertyDeclarationSyntax"/> instance for the <c>CompileOptions</c> property.
|
||||
/// </summary>
|
||||
/// <param name="bytecodeInfo">The input bytecode info.</param>
|
||||
/// <returns>The resulting <see cref="PropertyDeclarationSyntax"/> instance for the <c>CompileOptions</c> property.</returns>
|
||||
public static PropertyDeclarationSyntax GetCompileOptionsSyntax(EmbeddedBytecodeInfo bytecodeInfo)
|
||||
{
|
||||
// Get a formatted representation of the compile options being used
|
||||
ExpressionSyntax compileOptionsExpression =
|
||||
ParseExpression(
|
||||
bytecodeInfo.CompileOptions
|
||||
.ToString(CultureInfo.InvariantCulture)
|
||||
.Split(',')
|
||||
.Select(static name => $"global::ComputeSharp.D2D1.D2D1CompileOptions.{name.Trim()}")
|
||||
.Aggregate("", static (left, right) => left.Length > 0 ? $"{left} | {right}" : right));
|
||||
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
// readonly ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.__Internals.ID2D1Shader.CompileOptions => <COMPILE_OPTIONS_EXPRESSION>;
|
||||
return
|
||||
PropertyDeclaration(IdentifierName("ComputeSharp.D2D1.D2D1CompileOptions"), Identifier(nameof(ID2D1Shader.CompileOptions)))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.D2D1.__Internals.{nameof(ID2D1Shader)}")))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExpressionBody(ArrowExpressionClause(compileOptionsExpression))
|
||||
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken));
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,11 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
CompilationUnitSyntax shaderProfileCompilationUnit = GetCompilationUnitFromMember(item.Hierarchy, shaderProfileProperty, skipLocalsInit: false);
|
||||
|
||||
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.ShaderProfile.g.cs", shaderProfileCompilationUnit.GetText(Encoding.UTF8));
|
||||
|
||||
PropertyDeclarationSyntax compileOptionsProperty = LoadBytecode.GetCompileOptionsSyntax(item.BytecodeInfo);
|
||||
CompilationUnitSyntax compileOptionsCompilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, compileOptionsProperty, canUseSkipLocalsInit: false);
|
||||
|
||||
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.CompileOptions.g.cs", compileOptionsCompilationUnit.GetText(Encoding.UTF8));
|
||||
});
|
||||
|
||||
// Get the output buffer info (hierarchy and output buffers)
|
||||
|
||||
@@ -137,6 +137,16 @@ public interface ID2D1Shader
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
D2D1ShaderProfile ShaderProfile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the compile options for the current shader.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This compile options are 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")]
|
||||
D2D1CompileOptions CompileOptions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads the bytecode for the current shader.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする