Centralize all logic generation into initial transform
このコミットが含まれているのは:
1 親
2fba1f9730
コミット
6900923431
2ファイル変更
+14
-40
検索条件に一致するファイルはありません
@@ -94,6 +94,16 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
ImmutableArray<byte> bytecode = LoadBytecode.GetBytecode(threadIds, hlslSourceInfo.HlslSource, token, out DeferredDiagnosticInfo? diagnostic);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
EmbeddedBytecodeInfo bytecodeInfo = new(
|
||||
threadIds.X,
|
||||
threadIds.Y,
|
||||
threadIds.Z,
|
||||
bytecode);
|
||||
|
||||
return new ShaderInfo(
|
||||
Hierarchy: HierarchyInfo.From(typeSymbol),
|
||||
DispatchData: new DispatchDataInfo(
|
||||
@@ -103,6 +113,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
root32BitConstantCount),
|
||||
DispatchMetadata: dispatchMetadataInfo,
|
||||
HlslShaderSource: hlslSourceInfo,
|
||||
EmbeddedBytecode: bytecodeInfo,
|
||||
ThreadIds: threadIds,
|
||||
Diagnostcs: diagnostics.ToImmutable());
|
||||
})
|
||||
@@ -151,47 +162,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{nameof(LoadDispatchMetadata)}.g.cs", compilationUnit.GetText(Encoding.UTF8));
|
||||
});
|
||||
|
||||
// Compile the requested shader bytecodes
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, EmbeddedBytecodeInfo EmbeddedBytecode, DeferredDiagnosticInfo? Diagnostic)> embeddedBytecodeWithErrors =
|
||||
shaderInfoWithErrors
|
||||
.Select(static (item, token) =>
|
||||
{
|
||||
ImmutableArray<byte> bytecode = LoadBytecode.GetBytecode(item.ThreadIds, item.HlslShaderSource.HlslSource, token, out DeferredDiagnosticInfo? diagnostic);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
EmbeddedBytecodeInfo bytecodeInfo = new(
|
||||
item.ThreadIds.X,
|
||||
item.ThreadIds.Y,
|
||||
item.ThreadIds.Z,
|
||||
bytecode);
|
||||
|
||||
return (item.Hierarchy, bytecodeInfo, diagnostic);
|
||||
});
|
||||
|
||||
// Gather the diagnostics
|
||||
IncrementalValuesProvider<DiagnosticInfo> embeddedBytecodeDiagnostics =
|
||||
embeddedBytecodeWithErrors
|
||||
.Select(static (item, token) => (item.Hierarchy.FullyQualifiedMetadataName, item.Diagnostic))
|
||||
.Where(static item => item.Diagnostic is not null)
|
||||
.Combine(context.CompilationProvider)
|
||||
.Select(static (item, token) =>
|
||||
{
|
||||
INamedTypeSymbol typeSymbol = item.Right.GetTypeByMetadataName(item.Left.FullyQualifiedMetadataName)!;
|
||||
|
||||
return DiagnosticInfo.Create(item.Left.Diagnostic!.Descriptor, typeSymbol, new object[] { typeSymbol }.Concat(item.Left.Diagnostic.Arguments).ToArray());
|
||||
});
|
||||
|
||||
// Output the diagnostics
|
||||
context.ReportDiagnostics(embeddedBytecodeDiagnostics);
|
||||
|
||||
// Get the TryGetBytecode() info (hierarchy and compiled bytecode)
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, EmbeddedBytecodeInfo EmbeddedBytecode)> embeddedBytecodeInfo =
|
||||
embeddedBytecodeWithErrors
|
||||
.Select(static (item, token) => (item.Hierarchy, item.EmbeddedBytecode));
|
||||
|
||||
// Generate the TryGetBytecode() methods
|
||||
context.RegisterSourceOutput(embeddedBytecodeInfo, static (context, item) =>
|
||||
context.RegisterSourceOutput(shaderInfoWithErrors, static (context, item) =>
|
||||
{
|
||||
MethodDeclarationSyntax tryGetBytecodeMethod = LoadBytecode.GetSyntax(item.EmbeddedBytecode, out Func<SyntaxNode, SourceText> fixup);
|
||||
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, tryGetBytecodeMethod, addSkipLocalsInitAttribute: false);
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SourceGenerators.Models;
|
||||
/// <param name="DispatchData">The gathered shader dispatch data.</param>
|
||||
/// <param name="DispatchMetadata">The gathered shader dispatch metadata.</param>
|
||||
/// <param name="HlslShaderSource">The processed HLSL source for the shader.</param>
|
||||
/// <param name="EmbeddedBytecode">The info on the compiled bytecode, if available.</param>
|
||||
/// <param name="ThreadIds">The thread ids for the shader, if compilation is requested.</param>
|
||||
/// <param name="Diagnostcs">The discovered diagnostics, if any.</param>
|
||||
internal sealed record ShaderInfo(
|
||||
@@ -17,5 +18,6 @@ internal sealed record ShaderInfo(
|
||||
DispatchDataInfo DispatchData,
|
||||
DispatchMetadataInfo DispatchMetadata,
|
||||
HlslShaderSourceInfo HlslShaderSource,
|
||||
EmbeddedBytecodeInfo EmbeddedBytecode,
|
||||
ThreadIdsInfo ThreadIds,
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs);
|
||||
新しいイシューから参照
ユーザーをブロックする