From 55ad39b817bdb75e828f02e31d9b6220c90fbcc9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 7 Aug 2022 18:04:24 +0200 Subject: [PATCH] Tweak diagnostics, add SampleInputAtPosition checks too --- .../Diagnostics/DiagnosticDescriptors.cs | 6 +++--- .../Mappings/HlslKnownMethods.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs index 760a0a62..086410da 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs @@ -638,16 +638,16 @@ internal static class DiagnosticDescriptors /// /// Gets a for when the [D2DRequiresPosition] attribute is missing. /// - /// Format: "The D2D1 shader of type {0} is calling a D2D1 API or another method that require the [D2DRequiresPosition] attribute to be used, but the shader type is not annotated accordingly". + /// Format: "The D2D1 shader of type {0} is using D2D1 APIs that require the [D2DRequiresPosition] attribute to be used (that is, D2D1.GetScenePosition() and D2D1.SampleInputAtPosition(int, float2)), but the shader type is not annotated accordingly". /// /// public static readonly DiagnosticDescriptor MissingD2DRequiresPositionAttribute = new DiagnosticDescriptor( id: "CMPSD2D0045", title: "Missing [D2DRequiresPosition] attribute", - messageFormat: "The D2D1 shader of type {0} is calling a D2D1 API or another method that require the [D2DRequiresPosition] attribute to be used, but the shader type is not annotated accordingly", + messageFormat: "The D2D1 shader of type {0} is using D2D1 APIs that require the [D2DRequiresPosition] attribute to be used (that is, D2D.GetScenePosition() and D2D.SampleInputAtPosition(int, float2)), but the shader type is not annotated accordingly", category: "ComputeSharp.D2D1.Shaders", defaultSeverity: DiagnosticSeverity.Error, isEnabledByDefault: true, - description: "A D2D1 shader using functionality that needs position info (ie. when [D2DRequiresPosition] is used) needs to be annotated accordingly.", + 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"); } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs index 05c451f4..5c502afc 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs @@ -18,7 +18,7 @@ partial class HlslKnownMethods /// Whether the method needs the [D2DRequiresPosition] annotation. public static bool NeedsD2DRequiresPositionAttribute(string name) { - return name == "ComputeSharp.D2D1.D2D.GetScenePosition"; + return name is "ComputeSharp.D2D1.D2D.GetScenePosition" or "ComputeSharp.D2D1.D2D.SampleInputAtPosition"; } ///