diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index 20d27c7e..49903409 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -245,26 +245,6 @@ internal static partial class HlslKnownTypes return KnownHlslTypeMetadataNames.TryGetValue(originalName, out mappedName); } - /// - /// Tracks an instance and returns an HLSL compatible type name. - /// - /// The input instance to process. - /// The collection of currently discovered types. - /// A type name that represents a type compatible with HLSL. - public static string TrackType(ITypeSymbol typeSymbol, ICollection discoveredTypes) - { - string typeName = typeSymbol.GetFullyQualifiedName(); - - discoveredTypes.Add((INamedTypeSymbol)typeSymbol); - - if (TryGetMappedName(typeName, out string? mappedName)) - { - return mappedName!; - } - - return typeName.ToHlslIdentifierName(); - } - /// /// Gets the sequence of unique custom types from a collection of discovered types. /// diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs index 1c197f57..f4999445 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Tracking.cs @@ -18,6 +18,17 @@ partial class HlslSourceRewriter protected TypeSyntax TrackType(SyntaxNode node, SemanticModel semanticModel) { ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(node, CancellationToken).Type!; + + return TrackType(typeSymbol); + } + + /// + /// Tracks an instance and returns the HLSL compatible . + /// + /// The input instance to process. + /// A instance that represents a type compatible with HLSL. + protected TypeSyntax TrackType(ITypeSymbol typeSymbol) + { string typeName = typeSymbol.GetFullyQualifiedName(); DiscoveredTypes.Add((INamedTypeSymbol)typeSymbol); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index d0e378ad..a0d66410 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -627,7 +627,7 @@ internal sealed partial class ShaderSourceRewriter( // Track and rewrite the discarded declaration if (SemanticModel.For(node).GetOperation(node.Expression, CancellationToken) is IDiscardOperation operation) { - TypeSyntax typeSyntax = ParseTypeName(HlslKnownTypes.TrackType(operation.Type!, DiscoveredTypes)); + TypeSyntax typeSyntax = TrackType(operation.Type!); string identifier = $"__implicit{this.implicitVariables.Count}"; // Add the variable to the list of implicit declarations