Add D2D1 resource texture types to HlslKnownTypes
このコミットが含まれているのは:
1 親
eda4bd43ff
コミット
b28d3f2500
2ファイル変更
+34
-5
検索条件に一致するファイルはありません
@@ -1,4 +1,5 @@
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using System;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.Mappings;
|
||||
@@ -6,11 +7,39 @@ namespace ComputeSharp.SourceGeneration.Mappings;
|
||||
/// <inheritdoc/>
|
||||
partial class HlslKnownTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks whether or not a given type name matches a resource texture type.
|
||||
/// </summary>
|
||||
/// <param name="typeName">The input type name to check.</param>
|
||||
/// <returns>Whether or not <paramref name="typeName"/> represents a readonly typed resource type.</returns>
|
||||
public static bool IsResourceTextureType(string typeName)
|
||||
{
|
||||
return typeName switch
|
||||
{
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture1D" or
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture2D" or
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture3D" => true,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public static partial string GetMappedName(INamedTypeSymbol typeSymbol)
|
||||
{
|
||||
string typeName = typeSymbol.GetFullMetadataName();
|
||||
|
||||
// Special case for resource texture types
|
||||
if (IsResourceTextureType(typeName))
|
||||
{
|
||||
return typeName switch
|
||||
{
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture1D" => "Texture1D",
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture2D" => "Texture2D",
|
||||
"ComputeSharp.D2D1.D2D1ResourceTexture3D" => "Texture3D",
|
||||
_ => throw new ArgumentException()
|
||||
};
|
||||
}
|
||||
|
||||
// The captured field is of an HLSL primitive type
|
||||
if (KnownHlslTypes.TryGetValue(typeName, out string? mappedType))
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ partial class HlslKnownTypes
|
||||
"ComputeSharp.ConstantBuffer`1" or
|
||||
"ComputeSharp.ReadOnlyBuffer`1" or
|
||||
"ComputeSharp.ReadWriteBuffer`1" => true,
|
||||
_ => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ partial class HlslKnownTypes
|
||||
"ComputeSharp.IReadOnlyTexture3D`1" => true,
|
||||
"ComputeSharp.IReadOnlyNormalizedTexture2D`1" or
|
||||
"ComputeSharp.IReadOnlyNormalizedTexture3D`1" => true,
|
||||
_ => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ partial class HlslKnownTypes
|
||||
"ComputeSharp.ReadWriteTexture3D`2" or
|
||||
"ComputeSharp.IReadWriteNormalizedTexture2D`1" or
|
||||
"ComputeSharp.IReadWriteNormalizedTexture3D`1" => true,
|
||||
_ => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ partial class HlslKnownTypes
|
||||
"ComputeSharp.IReadWriteNormalizedTexture2D`1" or
|
||||
"ComputeSharp.IReadOnlyNormalizedTexture3D`1" or
|
||||
"ComputeSharp.IReadWriteNormalizedTexture3D`1" => true,
|
||||
_ => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする