Remove DispatchDataInfo model
このコミットが含まれているのは:
1 親
8f2afaef99
コミット
6532a20479
5ファイル変更
+23
-25
検索条件に一致するファイルはありません
+3
-3
@@ -19,9 +19,9 @@ partial class ID2D1ShaderGenerator
|
||||
/// <summary>
|
||||
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>InitializeFromDispatchData</c> method.
|
||||
/// </summary>
|
||||
/// <param name="dispatchInfo">The dispatch info gathered for the current shader.</param>
|
||||
/// <param name="fields">The discovered fields of the current shader.</param>
|
||||
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>InitializeFromDispatchData</c> method.</returns>
|
||||
public static MethodDeclarationSyntax GetSyntax(DispatchDataInfo dispatchInfo)
|
||||
public static MethodDeclarationSyntax GetSyntax(EquatableArray<FieldInfo> fields)
|
||||
{
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
@@ -35,7 +35,7 @@ partial class ID2D1ShaderGenerator
|
||||
.AddParameterListParameters(Parameter(Identifier("data")).WithType(
|
||||
GenericName(Identifier("global::System.ReadOnlySpan"))
|
||||
.AddTypeArgumentListArguments(PredefinedType(Token(SyntaxKind.ByteKeyword)))))
|
||||
.WithBody(Block(GetDispatchDataUnloadingStatements(dispatchInfo.FieldInfos)));
|
||||
.WithBody(Block(GetDispatchDataUnloadingStatements(fields)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+10
-5
@@ -24,19 +24,24 @@ partial class ID2D1ShaderGenerator
|
||||
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>LoadDispatchDataMethod</c> method.
|
||||
/// </summary>
|
||||
/// <param name="hierarchyInfo">The hiararchy info of the shader type.</param>
|
||||
/// <param name="dispatchInfo">The dispatch info gathered for the current shader.</param>
|
||||
/// <param name="fields">The description on shader instance fields.</param>
|
||||
/// <param name="constantBufferSizeInBytes">The size of the shader constant buffer.</param>
|
||||
/// <param name="additionalTypes">Any additional <see cref="TypeDeclarationSyntax"/> instances needed by the generated code, if needed.</param>
|
||||
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>LoadDispatchDataMethod</c> method.</returns>
|
||||
public static MethodDeclarationSyntax GetSyntax(HierarchyInfo hierarchyInfo, DispatchDataInfo dispatchInfo, out TypeDeclarationSyntax[] additionalTypes)
|
||||
public static MethodDeclarationSyntax GetSyntax(
|
||||
HierarchyInfo hierarchyInfo,
|
||||
EquatableArray<FieldInfo> fields,
|
||||
int constantBufferSizeInBytes,
|
||||
out TypeDeclarationSyntax[] additionalTypes)
|
||||
{
|
||||
// Declare the mapping constant buffer type, if needed (ie. if the shader has at least one field)
|
||||
if (dispatchInfo.FieldInfos.Length == 0)
|
||||
if (fields.Length == 0)
|
||||
{
|
||||
additionalTypes = Array.Empty<TypeDeclarationSyntax>();
|
||||
}
|
||||
else
|
||||
{
|
||||
additionalTypes = new[] { GetConstantBufferDeclaration(hierarchyInfo, dispatchInfo.FieldInfos, dispatchInfo.ConstantBufferSizeInBytes) };
|
||||
additionalTypes = new[] { GetConstantBufferDeclaration(hierarchyInfo, fields, constantBufferSizeInBytes) };
|
||||
}
|
||||
|
||||
// This code produces a method declaration as follows:
|
||||
@@ -51,7 +56,7 @@ partial class ID2D1ShaderGenerator
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword), Token(SyntaxKind.UnsafeKeyword))
|
||||
.AddTypeParameterListParameters(TypeParameter(Identifier("TLoader")))
|
||||
.AddParameterListParameters(Parameter(Identifier("loader")).AddModifiers(Token(SyntaxKind.RefKeyword)).WithType(IdentifierName("TLoader")))
|
||||
.WithBody(Block(GetDispatchDataLoadingStatements(dispatchInfo.FieldInfos, dispatchInfo.ConstantBufferSizeInBytes)));
|
||||
.WithBody(Block(GetDispatchDataLoadingStatements(fields, constantBufferSizeInBytes)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -144,7 +144,8 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
EffectDescription: effectDescription,
|
||||
EffectCategory: effectCategory,
|
||||
EffectAuthor: effectAuthor,
|
||||
DispatchData: new DispatchDataInfo(fieldInfos, constantBufferSizeInBytes),
|
||||
ConstantBufferSizeInBytes: constantBufferSizeInBytes,
|
||||
Fields: fieldInfos,
|
||||
InputTypes: new InputTypesInfo(inputTypes),
|
||||
ResourceTextureDescriptions: new ResourceTextureDescriptionsInfo(resourceTextureDescriptions),
|
||||
HlslShaderSource: new HlslShaderSourceInfo(
|
||||
@@ -279,15 +280,15 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
});
|
||||
|
||||
// Get the info for InitializeFromDispatchData() and LoadDispatchData() (hierarchy and dispatch data)
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, DispatchDataInfo Dispatch)> dispatchDataInfo =
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, EquatableArray<FieldInfo> Fields, int ConstantBufferSizeInBytes)> dispatchDataInfo =
|
||||
shaderInfoWithErrors
|
||||
.Select(static (item, _) => (item.Hierarchy, item.DispatchData));
|
||||
.Select(static (item, _) => (item.Hierarchy, item.Fields, item.ConstantBufferSizeInBytes));
|
||||
|
||||
// Generate the InitializeFromDispatchData() and LoadDispatchData() methods
|
||||
context.RegisterSourceOutput(dispatchDataInfo, static (context, item) =>
|
||||
{
|
||||
MethodDeclarationSyntax initializeFromDispatchDataMethod = InitializeFromDispatchData.GetSyntax(item.Dispatch);
|
||||
MethodDeclarationSyntax loadDispatchDataMethod = LoadDispatchData.GetSyntax(item.Hierarchy, item.Dispatch, out TypeDeclarationSyntax[] additionalTypes);
|
||||
MethodDeclarationSyntax initializeFromDispatchDataMethod = InitializeFromDispatchData.GetSyntax(item.Fields);
|
||||
MethodDeclarationSyntax loadDispatchDataMethod = LoadDispatchData.GetSyntax(item.Hierarchy, item.Fields, item.ConstantBufferSizeInBytes, out TypeDeclarationSyntax[] additionalTypes);
|
||||
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMembers(
|
||||
item.Hierarchy,
|
||||
memberDeclarations: new (MemberDeclarationSyntax, bool)[] { (initializeFromDispatchDataMethod, false), (loadDispatchDataMethod, true) },
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// <param name="EffectDescription">The effect description for the shader type, if available.</param>
|
||||
/// <param name="EffectCategory">The effect category for the shader type, if available.</param>
|
||||
/// <param name="EffectAuthor">The effect author for the shader type, if available.</param>
|
||||
/// <param name="DispatchData">The gathered shader dispatch data.</param>
|
||||
/// <param name="ConstantBufferSizeInBytes">The size of the shader constant buffer.</param>
|
||||
/// <param name="Fields">The description on shader instance fields.</param>
|
||||
/// <param name="InputTypes">The gathered input types for the shader.</param>
|
||||
/// <param name="ResourceTextureDescriptions">The gathered resource texture descriptions for the shader.</param>
|
||||
/// <param name="HlslShaderSource">The processed HLSL source for the shader.</param>
|
||||
@@ -27,7 +28,8 @@ internal sealed record D2D1ShaderInfo(
|
||||
string? EffectDescription,
|
||||
string? EffectCategory,
|
||||
string? EffectAuthor,
|
||||
DispatchDataInfo DispatchData,
|
||||
int ConstantBufferSizeInBytes,
|
||||
EquatableArray<FieldInfo> Fields,
|
||||
InputTypesInfo InputTypes,
|
||||
ResourceTextureDescriptionsInfo ResourceTextureDescriptions,
|
||||
HlslShaderSourceInfo HlslShaderSource,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model representing gathered info on a shader dispatch data.
|
||||
/// </summary>
|
||||
/// <param name="FieldInfos">The description on shader instance fields.</param>
|
||||
/// <param name="ConstantBufferSizeInBytes">The size of the shader constant buffer.</param>
|
||||
internal sealed record DispatchDataInfo(EquatableArray<FieldInfo> FieldInfos, int ConstantBufferSizeInBytes);
|
||||
新しいイシューから参照
ユーザーをブロックする