Add diagnostics for invalid resource texture setups
このコミットが含まれているのは:
1 親
8b42c7011e
コミット
fdc69ed292
4ファイル変更
+67
-6
検索条件に一致するファイルはありません
@@ -52,3 +52,6 @@ CMPSD2D0042 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github
|
||||
CMPSD2D0043 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0044 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0045 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0046 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0047 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0048 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -547,7 +547,7 @@ internal static class DiagnosticDescriptors
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor OutOfRangeInputIndex = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0039",
|
||||
title: "Our of range D2D1 shader input indices",
|
||||
title: "Out of range D2D1 shader input indices",
|
||||
messageFormat: "The D2D1 shader of type {0} is using some out of range input indices",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
@@ -595,7 +595,7 @@ internal static class DiagnosticDescriptors
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor OutOfRangeInputDescriptionIndex = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0042",
|
||||
title: "Our of range D2D1 shader input description indices",
|
||||
title: "Out of range D2D1 shader input description indices",
|
||||
messageFormat: "The D2D1 shader of type {0} is using some out of range input description indices",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
@@ -650,4 +650,52 @@ internal static class DiagnosticDescriptors
|
||||
isEnabledByDefault: true,
|
||||
description: "A D2D1 shader using functionality that needs position info (ie. when [D2DRequiresPosition] is used, which is mandatory when calling either D2D.GetScenePosition() or D2D.SampleInputAtPosition(int, float2)) needs to be annotated accordingly.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a shader with an out of range resource texture index (or more).
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D1 shader of type {0} is using some out of range resource texture indices"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor ResourceTextureIndexOverlappingWithInputIndex = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0046",
|
||||
title: "D2D1 shader resource texture indices overlapping input indices",
|
||||
messageFormat: "The D2D1 shader of type {0} is using some resource texture indices that overlap with the shader input indices",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A D2D1 shader must have all the indices of its resource textures in the valid range (between the input count and 16, exclusive).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a shader with an out of range resource texture index (or more).
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D1 shader of type {0} is using some out of range resource texture indices"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor OutOfRangeResourceTextureIndex = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0047",
|
||||
title: "Out of range D2D1 shader resource texture indices",
|
||||
messageFormat: "The D2D1 shader of type {0} is using some out of range resource texture indices",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A D2D1 shader must have all the indices of its resource textures in the valid range (between the input count and 16, exclusive).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for repeated indices for D2D resource texture indices.
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D1 shader of type {0} is using repeated indices for some of its [D2DResourceTextureIndex] attributes"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor RepeatedD2DResourceTextureIndices = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0048",
|
||||
title: "Repeated D2D1 shader resource texture indices",
|
||||
messageFormat: "The D2D1 shader of type {0} is using repeated indices for some of its [D2DResourceTextureIndex] attributes",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A D2D1 shader must only have unique indices for all of its [D2DResourceTextureIndex] attributes.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
+1
-1
@@ -57,7 +57,7 @@ partial class ID2D1ShaderGenerator
|
||||
|
||||
inputDescriptions = ImmutableArray<InputDescription>.Empty;
|
||||
|
||||
// Validate the input count (ignore if invalid, this will be validated by the HLSL source generator)
|
||||
// Validate the input count (ignore if invalid, this will be validated by GetInputType() generator)
|
||||
if (inputCount is not (>= 0 and <= 8))
|
||||
{
|
||||
goto End;
|
||||
|
||||
+13
-3
@@ -5,6 +5,7 @@ using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Mappings;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using static ComputeSharp.D2D1.SourceGenerators.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators;
|
||||
|
||||
@@ -72,10 +73,19 @@ partial class ID2D1ShaderGenerator
|
||||
// Extract the resource texture descriptions for the rest of the pipeline
|
||||
resourceTextureDescriptions = resourceTextureInfos.Select(static info => new ResourceTextureDescription(info.Index, info.Rank)).ToImmutableArray();
|
||||
|
||||
// If the input count is invalid, do nothing and avoid emitting potentially incorrect
|
||||
// diagnostics based on the resource texture indices with respect to the input count.
|
||||
// The GetInputType() generator has already emitted diagnostic for this error, so this
|
||||
// generator can just wait for users to go back and fix that issue before proceeding.
|
||||
if (inputCount is not (>= 0 and <= 8))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate that the resource texture indices don't overlap with the shader inputs
|
||||
if (resourceTextureInfos.Any(info => info.Index < inputCount))
|
||||
{
|
||||
// TODO: overlap with textures
|
||||
diagnostics.Add(ResourceTextureIndexOverlappingWithInputIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +93,7 @@ partial class ID2D1ShaderGenerator
|
||||
// Validate that no resource texture has an index greater than or equal to 16
|
||||
if (resourceTextureInfos.Any(info => info.Index >= 16))
|
||||
{
|
||||
// TODO: diagnostic
|
||||
diagnostics.Add(OutOfRangeResourceTextureIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +103,7 @@ partial class ID2D1ShaderGenerator
|
||||
// All input description indices must be unique
|
||||
if (resourceTextureIndices.Count != resourceTextureInfos.Count)
|
||||
{
|
||||
// TODO: diagnostic
|
||||
diagnostics.Add(RepeatedD2DResourceTextureIndices, structDeclarationSymbol, structDeclarationSymbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする