Fixed mapping of built-in vector type properties
このコミットが含まれているのは:
1 親
b971905fe6
コミット
e7b5410d03
2ファイル変更
+7
-11
検索条件に一致するファイルはありません
@@ -109,9 +109,10 @@ namespace ComputeSharp.Shaders.Extensions
|
||||
}
|
||||
|
||||
// Process the input node if it's a known method invocation
|
||||
if (HlslKnownMethods.TryGetMappedName(containingMemberSymbolInfo.Symbol, memberSymbol) is string mappedName)
|
||||
if (HlslKnownMethods.TryGetMappedName(containingMemberSymbolInfo.Symbol, memberSymbol, out string? mappedName))
|
||||
{
|
||||
return SyntaxFactory.IdentifierName(mappedName).WithLeadingTrivia(node.GetLeadingTrivia()).WithTrailingTrivia(node.GetTrailingTrivia());
|
||||
string expression = memberSymbol.IsStatic ? mappedName : $"{node.Expression}{mappedName}";
|
||||
return SyntaxFactory.IdentifierName(expression).WithLeadingTrivia(node.GetLeadingTrivia()).WithTrailingTrivia(node.GetTrailingTrivia());
|
||||
}
|
||||
|
||||
// Handle static fields as a special case
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -262,21 +263,15 @@ namespace ComputeSharp.Shaders.Mappings
|
||||
/// </summary>
|
||||
/// <param name="containingMemberSymbol">The containing member symbol for the method to check</param>
|
||||
/// <param name="memberSymbol">The symbol for the method to check</param>
|
||||
/// <param name="mapped">The mapped name, if one is found</param>
|
||||
/// <returns>The HLSL-compatible method name that can be used in an HLSL shader</returns>
|
||||
[Pure]
|
||||
public static string? TryGetMappedName(ISymbol containingMemberSymbol, ISymbol memberSymbol)
|
||||
public static bool TryGetMappedName(ISymbol containingMemberSymbol, ISymbol memberSymbol, [NotNullWhen(true)] out string? mapped)
|
||||
{
|
||||
string fullTypeName = containingMemberSymbol.IsStatic ? containingMemberSymbol.ToString() : memberSymbol.ContainingType.ToString();
|
||||
|
||||
// Check if the target method is a known method
|
||||
if (KnownMethods.TryGetValue($"{fullTypeName}{Type.Delimiter}{memberSymbol.Name}", out string mapped))
|
||||
{
|
||||
// Return the static method if possible, otherwise access the parent instance
|
||||
if (memberSymbol.IsStatic) return mapped;
|
||||
return $"{containingMemberSymbol.Name}{mapped}";
|
||||
}
|
||||
|
||||
return null;
|
||||
return KnownMethods.TryGetValue($"{fullTypeName}{Type.Delimiter}{memberSymbol.Name}", out mapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする