Move HlslKnownSizes to shared generation project
このコミットが含まれているのは:
1 親
c8ca41d4c0
コミット
5a478d68ab
5ファイル変更
+4
-62
検索条件に一致するファイルはありません
+1
-2
@@ -4,10 +4,9 @@ using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics;
|
||||
using ComputeSharp.D2D1Interop.SourceGenerators.Mappings;
|
||||
using ComputeSharp.D2D1Interop.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Mappings;
|
||||
using ComputeSharp.SourceGenerators.Mappings;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using static ComputeSharp.D2D1Interop.SourceGenerators.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.SourceGenerators.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains and maps known HLSL types to their alignment sizes.
|
||||
/// </summary>
|
||||
internal static class HlslKnownSizes
|
||||
{
|
||||
/// <summary>
|
||||
/// The mapping of supported known sizes to HLSL type names.
|
||||
/// </summary>
|
||||
private static readonly IReadOnlyDictionary<string, (int, int)> KnownSizes = BuildKnownSizesMap();
|
||||
|
||||
/// <summary>
|
||||
/// Builds the mapping of known type sizes and alignments.
|
||||
/// </summary>
|
||||
private static IReadOnlyDictionary<string, (int, int)> BuildKnownSizesMap()
|
||||
{
|
||||
Dictionary<string, (int, int)> knownSizes = new()
|
||||
{
|
||||
[typeof(bool).FullName] = (4, 4),
|
||||
[typeof(int).FullName] = (4, 4),
|
||||
[typeof(uint).FullName] = (4, 4),
|
||||
[typeof(float).FullName] = (4, 4),
|
||||
[typeof(double).FullName] = (8, 8),
|
||||
|
||||
[typeof(Vector2).FullName] = (8, 4),
|
||||
[typeof(Vector3).FullName] = (12, 4),
|
||||
[typeof(Vector4).FullName] = (16, 4)
|
||||
};
|
||||
|
||||
foreach (
|
||||
var type in
|
||||
from type in Assembly.GetExecutingAssembly().ExportedTypes
|
||||
where Regex.IsMatch(type.FullName, @"^ComputeSharp\.(Bool|Double|Float|Int|UInt)")
|
||||
select type)
|
||||
{
|
||||
knownSizes.Add(type.FullName, (type.StructLayoutAttribute.Size, type.StructLayoutAttribute.Pack));
|
||||
}
|
||||
|
||||
return knownSizes;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public static (int Size, int Pack) GetTypeInfo(string typeName)
|
||||
{
|
||||
return KnownSizes[typeName];
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\StringExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxNodeExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownKeywords.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownSizes.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Mappings;
|
||||
namespace ComputeSharp.SourceGeneration.Mappings;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains and maps known HLSL types to their alignment sizes.
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGenerators.Diagnostics;
|
||||
using ComputeSharp.SourceGeneration.Mappings;
|
||||
using ComputeSharp.SourceGenerators.Mappings;
|
||||
using ComputeSharp.SourceGenerators.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする