Add diagnostic for invalid D2D1 resource texture element type
このコミットが含まれているのは:
1 親
97a87500e2
コミット
3515c4402b
3ファイル変更
+31
検索条件に一致するファイルはありません
@@ -57,3 +57,4 @@ CMPSD2D0047 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github
|
||||
CMPSD2D0048 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0049 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0050 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPSD2D0051 | ComputeSharp.D2D1.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -728,4 +728,20 @@ partial class DiagnosticDescriptors
|
||||
isEnabledByDefault: true,
|
||||
description: "All fields of a D2D1 resource texture type must be annotated using the [D2DResourceTextureIndex] attribute.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a resource texture using an invalid element type.
|
||||
/// <para>
|
||||
/// Format: <c>"The field \"{0}\" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidResourceTextureElementType = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0051",
|
||||
title: "Missing [D2DResourceTextureIndex] attribute",
|
||||
messageFormat: "The field \"{0}\" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The element type of D2D1 resource texture fields in a D2D1 shader must be either float or float4.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
+14
@@ -132,6 +132,20 @@ partial class ID2D1ShaderGenerator
|
||||
// Handle resource textures as a special case
|
||||
if (HlslKnownTypes.IsResourceTextureType(metadataName))
|
||||
{
|
||||
ITypeSymbol resourceTextureTypeArgumentSymbol = typeSymbol.TypeArguments[0];
|
||||
|
||||
// Validate that the type argument is only either float or float4
|
||||
if (!resourceTextureTypeArgumentSymbol.HasFullyQualifiedName("System.Single") &&
|
||||
!resourceTextureTypeArgumentSymbol.HasFullyQualifiedName("ComputeSharp.Float4"))
|
||||
{
|
||||
diagnostics.Add(
|
||||
InvalidResourceTextureElementType,
|
||||
fieldSymbol,
|
||||
fieldSymbol.Name,
|
||||
structDeclarationSymbol,
|
||||
fieldSymbol.Type);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
// If [D2DResourceTextureIndex] is present, get the resource texture index.
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする