Implemented initial dispatch data loader SG logic

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-29 23:54:05 +01:00
1 親 29e2931a8a
コミット 2b2ec28597
4ファイル変更
+56 -5

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

+14 -2
ファイルの表示
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Numerics;
namespace ComputeSharp.SourceGenerators.Mappings
@@ -9,9 +10,9 @@ namespace ComputeSharp.SourceGenerators.Mappings
internal static class HlslKnownSizes
{
/// <summary>
/// Gets the mapping of supported known sizes to HLSL type names.
/// The mapping of supported known sizes to HLSL type names.
/// </summary>
public static IReadOnlyDictionary<string, (int Size, int Pack)> KnownSizes { get; } = new Dictionary<string, (int, int)>
private static IReadOnlyDictionary<string, (int, int)> KnownSizes = new Dictionary<string, (int, int)>
{
[typeof(bool).FullName] = (4, 4),
[typeof(int).FullName] = (4, 4),
@@ -43,5 +44,16 @@ namespace ComputeSharp.SourceGenerators.Mappings
[typeof(Double3).FullName] = (24, 8),
[typeof(Double3).FullName] = (32, 8)
};
/// <summary>
/// Gets the size and alignment info for a specified primitive type.
/// </summary>
/// <param name="typeName">The type name to get info for.</param>
/// <returns>The size and and alignment for the input type.</returns>
[Pure]
public static (int Size, int Pack) GetTypeInfo(string typeName)
{
return KnownSizes[typeName];
}
}
}
+12
ファイルの表示
@@ -78,6 +78,18 @@ namespace ComputeSharp.SourceGenerators.Mappings
};
}
/// <summary>
/// Checks whether or not a given type name matches a typed resource 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>
public static bool IsScalarOrVectorType(string typeName)
{
return
KnownTypes.ContainsKey(typeName) &&
typeName != typeof(ThreadIds).FullName;
}
/// <summary>
/// Gets the mapped HLSL-compatible type name for the input type symbol.
/// </summary>