Fixed overload resolution in matrix constructors
このコミットが含まれているのは:
1 親
ec3d8059c3
コミット
808dcbdf79
2ファイル変更
+71
-8
検索条件に一致するファイルはありません
@@ -15,6 +15,23 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
/// </summary>
|
||||
internal static class HlslKnownTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// The collection of known matrix types.
|
||||
/// </summary>
|
||||
private static readonly IReadOnlyCollection<Type> KnownMatrixTypes = BuildKnownMatrixTypes();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the mapping of known matrix types.
|
||||
/// </summary>
|
||||
[Pure]
|
||||
private static IReadOnlyCollection<Type> BuildKnownMatrixTypes()
|
||||
{
|
||||
return (
|
||||
from type in Assembly.GetExecutingAssembly().ExportedTypes
|
||||
where Regex.IsMatch(type.FullName, @"^ComputeSharp\.(Bool|Double|Float|Int|UInt)")
|
||||
select type).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The mapping of supported known types to HLSL types.
|
||||
/// </summary>
|
||||
@@ -39,11 +56,7 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
};
|
||||
|
||||
// Add all the mapped vector and matrix types
|
||||
foreach (
|
||||
var type in
|
||||
from type in Assembly.GetExecutingAssembly().ExportedTypes
|
||||
where Regex.IsMatch(type.FullName, @"^ComputeSharp\.(Bool|Double|Float|Int|UInt)")
|
||||
select type)
|
||||
foreach (var type in KnownMatrixTypes)
|
||||
{
|
||||
knownTypes.Add(type.FullName, type.Name.ToLower());
|
||||
}
|
||||
@@ -120,15 +133,35 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given type name matches a typed resource type.
|
||||
/// Checks whether or not a given type name matches a scalar or vector type.
|
||||
/// </summary>
|
||||
/// <param name="typeName">The input type name to check.</param>
|
||||
/// <returns>Whether or not <paramref name="typeName"/> represents a typed resource type.</returns>
|
||||
/// <returns>Whether or not <paramref name="typeName"/> represents a scalar or vector.</returns>
|
||||
public static bool IsScalarOrVectorType(string typeName)
|
||||
{
|
||||
return KnownTypes.ContainsKey(typeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given type name matches a vector type.
|
||||
/// </summary>
|
||||
/// <param name="typeName">The input type name to check.</param>
|
||||
/// <returns>Whether or not <paramref name="typeName"/> represents a vector type.</returns>
|
||||
public static bool IsVectorType(string typeName)
|
||||
{
|
||||
return HlslMappedVectorTypes.Any(type => type.FullName == typeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given type name matches a matrix type.
|
||||
/// </summary>
|
||||
/// <param name="typeName">The input type name to check.</param>
|
||||
/// <returns>Whether or not <paramref name="typeName"/> represents a matrix type.</returns>
|
||||
public static bool IsMatrixType(string typeName)
|
||||
{
|
||||
return KnownMatrixTypes.Any(type => type.FullName == typeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapped HLSL-compatible type name for the input type symbol.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする