Finished support for mapping type names from SG
このコミットが含まれているのは:
1 親
d0bfcefc79
コミット
0723c04b59
5ファイル変更
+46
-113
検索条件に一致するファイルはありません
@@ -41,7 +41,7 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
[typeof(Double2).FullName] = "double2",
|
||||
[typeof(Double3).FullName] = "double3",
|
||||
[typeof(Double4).FullName] = "double4",
|
||||
[typeof(ThreadIds).FullName] = "uint3",
|
||||
[typeof(ThreadIds).FullName] = "uint3"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -68,6 +68,38 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
typeName == "ComputeSharp.ReadWriteBuffer`1";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapped HLSL-compatible type name for the input type symbol.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The input type to map.</param>
|
||||
/// <returns>The HLSL-compatible type name that can be used in an HLSL shader.</returns>
|
||||
public static string GetMappedName(INamedTypeSymbol typeSymbol)
|
||||
{
|
||||
string typeName = typeSymbol.GetFullMetadataName();
|
||||
|
||||
// Special case for the structured buffer types
|
||||
if (IsStructuredBufferType(typeName))
|
||||
{
|
||||
string genericArgumentName = ((INamedTypeSymbol)typeSymbol.TypeArguments[0]).GetFullMetadataName();
|
||||
|
||||
// If the current type is a custom type, format it as needed
|
||||
if (!KnownTypes.TryGetValue(genericArgumentName, out string? mapped))
|
||||
{
|
||||
mapped = genericArgumentName.Replace(".", "__");
|
||||
}
|
||||
|
||||
// Construct the HLSL type name
|
||||
return typeName switch
|
||||
{
|
||||
"ComputeSharp.ReadOnlyBuffer`1" => $"StructuredBuffer<{mapped}>",
|
||||
"ComputeSharp.ReadWriteBuffer`1" => $"RWStructuredBuffer<{mapped}>",
|
||||
_ => throw new ArgumentException()
|
||||
};
|
||||
}
|
||||
|
||||
return KnownTypes[typeName];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mapped HLSL-compatible type name for the input type name.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする