Enable constructors support in DX12 shaders

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-02 19:13:26 +01:00
1 親 f6a39ef48a
コミット b685f09d06
5ファイル変更
+231 -29

検索条件に一致するファイルはありません

+7 -1
ファイルの表示
@@ -57,6 +57,7 @@ partial class ComputeShaderDescriptorGenerator
HashSet<INamedTypeSymbol> discoveredTypes = new(SymbolEqualityComparer.Default);
Dictionary<IMethodSymbol, MethodDeclarationSyntax> staticMethods = new(SymbolEqualityComparer.Default);
Dictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods = new(SymbolEqualityComparer.Default);
Dictionary<IMethodSymbol, (MethodDeclarationSyntax, MethodDeclarationSyntax)> constructors = new(SymbolEqualityComparer.Default);
Dictionary<IFieldSymbol, string> constantDefinitions = new(SymbolEqualityComparer.Default);
// Setup the semantic model and basic properties
@@ -90,6 +91,7 @@ partial class ComputeShaderDescriptorGenerator
discoveredTypes,
staticMethods,
instanceMethods,
constructors,
constantDefinitions,
isComputeShader,
token);
@@ -112,7 +114,8 @@ partial class ComputeShaderDescriptorGenerator
diagnostics,
structDeclarationSymbol,
discoveredTypes,
instanceMethods);
instanceMethods,
constructors);
token.ThrowIfCancellationRequested();
@@ -359,6 +362,7 @@ partial class ComputeShaderDescriptorGenerator
/// <param name="discoveredTypes">The collection of currently discovered types.</param>
/// <param name="staticMethods">The set of discovered and processed static methods.</param>
/// <param name="instanceMethods">The collection of discovered instance methods for custom struct types.</param>
/// <param name="constructors">The collection of discovered constructors for custom struct types.</param>
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
/// <param name="isComputeShader">Indicates whether or not <paramref name="structDeclarationSymbol"/> represents a compute shader.</param>
/// <param name="token">The <see cref="CancellationToken"/> used to cancel the operation, if needed.</param>
@@ -370,6 +374,7 @@ partial class ComputeShaderDescriptorGenerator
ICollection<INamedTypeSymbol> discoveredTypes,
IDictionary<IMethodSymbol, MethodDeclarationSyntax> staticMethods,
IDictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods,
IDictionary<IMethodSymbol, (MethodDeclarationSyntax, MethodDeclarationSyntax)> constructors,
IDictionary<IFieldSymbol, string> constantDefinitions,
bool isComputeShader,
CancellationToken token)
@@ -419,6 +424,7 @@ partial class ComputeShaderDescriptorGenerator
discoveredTypes,
staticMethods,
instanceMethods,
constructors,
constantDefinitions,
diagnostics,
isShaderEntryPoint);
+6 -6
ファイルの表示
@@ -670,19 +670,19 @@ partial class DiagnosticDescriptors
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
/// <summary>
/// Gets a <see cref="DiagnosticDescriptor"/> for a method invocation that is not valid from a shader.
/// Gets a <see cref="DiagnosticDescriptor"/> for a method or constructor invocation that is not valid from a shader.
/// <para>
/// Format: <c>"The method {0} cannot be used in a shader (methods need to either be HLSL intrinsics or with source available for analysis)"</c>.
/// Format: <c>"The method or constructor {0} cannot be used in a shader (methods need to either be HLSL intrinsics or with source available for analysis)"</c>.
/// </para>
/// </summary>
public static readonly DiagnosticDescriptor InvalidMethodCall = new(
public static readonly DiagnosticDescriptor InvalidMethodOrConstructorCall = new(
id: "CMPS0049",
title: "Invalid method invocation from a shader",
messageFormat: "The method {0} cannot be used in a shader (methods need to either be HLSL intrinsics or with source available for analysis)",
title: "Invalid method or constructor invocation from a shader",
messageFormat: "The method or constructor {0} cannot be used in a shader (methods or constructors need to either be HLSL intrinsics or with source available for analysis)",
category: "ComputeSharp.Shaders",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Shaders can only invoke methods that are either HLSL intrinsics or with source available for analysis.",
description: "Shaders can only invoke methods or constructors that are either HLSL intrinsics or with source available for analysis.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
/// <summary>