Fix shader attribute diagnostics for input-less shaders
このコミットが含まれているのは:
1 親
5899a6667a
コミット
993308f6e0
2ファイル変更
+10
-12
検索条件に一致するファイルはありません
@@ -475,13 +475,13 @@ internal static class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a invalid D2D input count value.
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D1 shader of type {0} is using an incorrect value for [D2DInputCount] (the number of inputs must be in the [1, 8] range)"</c>.
|
||||
/// Format: <c>"The D2D1 shader of type {0} is using an incorrect value for [D2DInputCount] (the number of inputs must be in the [0, 8] range)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidD2DInputCount = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0035",
|
||||
title: "Invalid D2D1 shader input count",
|
||||
messageFormat: "The D2D1 shader of type {0} is using an incorrect value for [D2DInputCount] (the number of inputs must be in the [1, 8] range)",
|
||||
messageFormat: "The D2D1 shader of type {0} is using an incorrect value for [D2DInputCount] (the number of inputs must be in the [0, 8] range)",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -549,6 +549,6 @@ internal static class DiagnosticDescriptors
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "A D2D1 shader must have all the indices of its simple and complex inputs in the valid range (between 1 and the number of declared inputs).",
|
||||
description: "A D2D1 shader must have all the indices of its simple and complex inputs in the valid range (between 0 and the number of declared inputs).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
+7
-9
@@ -417,13 +417,19 @@ partial class ID2D1ShaderGenerator
|
||||
inputComplexIndices = inputComplexIndicesBuilder.ToImmutable();
|
||||
|
||||
// Validate the input count
|
||||
if (rawInputCount is not (>= 1 and <= 8))
|
||||
if (rawInputCount is not (>= 0 and <= 8))
|
||||
{
|
||||
diagnostics.Add(InvalidD2DInputCount, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// All simple indices must be in range
|
||||
if (inputSimpleIndicesBuilder.Concat(inputComplexIndicesBuilder).Any(i => (uint)i >= rawInputCount))
|
||||
{
|
||||
diagnostics.Add(OutOfRangeInputIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
}
|
||||
|
||||
HashSet<int> inputSimpleIndicesAsSet = new(inputSimpleIndicesBuilder);
|
||||
HashSet<int> inputComplexIndicesAsSet = new(inputComplexIndicesBuilder);
|
||||
|
||||
@@ -450,14 +456,6 @@ partial class ID2D1ShaderGenerator
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int maxAllowedInputIndex = rawInputCount - 1;
|
||||
|
||||
// All simple indices must be in range
|
||||
if (inputSimpleIndicesBuilder.Concat(inputComplexIndicesBuilder).Any(i => i < 0 || i > maxAllowedInputIndex))
|
||||
{
|
||||
diagnostics.Add(OutOfRangeInputIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする