Add tracking steps to DX12/D2D source generators
このコミットが含まれているのは:
1 親
4f75380750
コミット
50c6a9435f
4ファイル変更
+49
-7
検索条件に一致するファイルはありません
@@ -2,6 +2,7 @@ using System.Collections.Immutable;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Constants;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
@@ -197,13 +198,21 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
HlslInfo: hlslInfo,
|
||||
Diagnostcs: diagnostics.ToImmutable());
|
||||
})
|
||||
.WithTrackingName(WellKnownTrackingNames.Execute)
|
||||
.Where(static item => item is not null)!;
|
||||
|
||||
// We need to create two more incremental steps to ensure we correctly emit diagnostics and re-generate sources:
|
||||
// - One with just the diagnostics, which will trigger every time any of them changes
|
||||
// - One with just the shader info (and no diagnostics), so that changes there don't trigger generation unnecessarily
|
||||
IncrementalValuesProvider<EquatableArray<DiagnosticInfo>> diagnosticInfo = shaderInfo.Select(static (item, _) => item.Diagnostcs);
|
||||
IncrementalValuesProvider<D2D1ShaderInfo> outputInfo = shaderInfo.Select(static (item, _) => item with { Diagnostcs = default });
|
||||
// We need to create two more incremental steps to ensure we correctly emit diagnostics and re-generate sources.
|
||||
// First, select an incremental provider with just the diagnostics, which will trigger every time any of them changes.
|
||||
IncrementalValuesProvider<EquatableArray<DiagnosticInfo>> diagnosticInfo =
|
||||
shaderInfo
|
||||
.Select(static (item, _) => item.Diagnostcs)
|
||||
.WithTrackingName(WellKnownTrackingNames.Diagnostics);
|
||||
|
||||
// Next, select one with just the shader info (and no diagnostics), so that changes there don't trigger generation unnecessarily
|
||||
IncrementalValuesProvider<D2D1ShaderInfo> outputInfo =
|
||||
shaderInfo
|
||||
.Select(static (item, _) => item with { Diagnostcs = default })
|
||||
.WithTrackingName(WellKnownTrackingNames.Output);
|
||||
|
||||
// Output the diagnostics, if any
|
||||
context.ReportDiagnostics(diagnosticInfo);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<Import_RootNamespace>ComputeSharp.SourceGeneration.Hlsl</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Constants\WellKnownTrackingNames.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotAccessibleFieldTypeInGeneratedShaderDescriptorAttributeTargetAnalyzerBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotReadOnlyShaderTypeWithFieldsAnalyzerBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\NotAccessibleGeneratedShaderDescriptorAttributeTargetAnalyzerBase.cs" />
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace ComputeSharp.SourceGeneration.Constants;
|
||||
|
||||
/// <summary>
|
||||
/// The well known names for tracking steps, to test the incremental generators.
|
||||
/// </summary>
|
||||
internal static class WellKnownTrackingNames
|
||||
{
|
||||
/// <summary>
|
||||
/// The initial <see cref="Microsoft.CodeAnalysis.SyntaxValueProvider.ForAttributeWithMetadataName"/> transform node.
|
||||
/// </summary>
|
||||
public const string Execute = nameof(Execute);
|
||||
|
||||
/// <summary>
|
||||
/// The filtered transform with just output diagnostics.
|
||||
/// </summary>
|
||||
public const string Diagnostics = nameof(Diagnostics);
|
||||
|
||||
/// <summary>
|
||||
/// The filtered transform with just output sources.
|
||||
/// </summary>
|
||||
public const string Output = nameof(Output);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGeneration.Constants;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
@@ -146,11 +147,20 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
|
||||
HlslInfo: hlslInfo,
|
||||
Diagnostcs: diagnostics.ToImmutable());
|
||||
})
|
||||
.WithTrackingName(WellKnownTrackingNames.Execute)
|
||||
.Where(static item => item is not null)!;
|
||||
|
||||
// Split the diagnostics, and drop them from the output provider (see more notes in the D2D1 generator)
|
||||
IncrementalValuesProvider<EquatableArray<DiagnosticInfo>> diagnosticInfo = shaderInfo.Select(static (item, _) => item.Diagnostcs);
|
||||
IncrementalValuesProvider<ShaderInfo> outputInfo = shaderInfo.Select(static (item, _) => item with { Diagnostcs = default });
|
||||
IncrementalValuesProvider<EquatableArray<DiagnosticInfo>> diagnosticInfo =
|
||||
shaderInfo
|
||||
.Select(static (item, _) => item.Diagnostcs)
|
||||
.WithTrackingName(WellKnownTrackingNames.Diagnostics);
|
||||
|
||||
// Gather the models to produce sources for
|
||||
IncrementalValuesProvider<ShaderInfo> outputInfo =
|
||||
shaderInfo
|
||||
.Select(static (item, _) => item with { Diagnostcs = default })
|
||||
.WithTrackingName(WellKnownTrackingNames.Output);
|
||||
|
||||
// Output the diagnostics, if any
|
||||
context.ReportDiagnostics(diagnosticInfo);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする