Added DispatchSize type

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-08 13:36:59 +01:00
1 親 b12c5501a8
コミット 1365f963e9
4ファイル変更
+272 -1

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

+2 -1
ファイルの表示
@@ -17,10 +17,11 @@
<Compile Include="..\ComputeSharp\Core\Attributes\__Internals\ComputeRoot32BitConstantsAttribute.cs" Link="Core\Attributes\__Internals\ComputeRoot32BitConstantsAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\__Internals\IComputeShaderSourceAttribute.cs" Link="Core\Attributes\__Internals\IComputeShaderSourceAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\__Internals\ShaderMethodSourceAttribute.cs" Link="Core\Attributes\__Internals\ShaderMethodSourceAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\DispatchSize.cs" Link="Core\Dispatch\DispatchSize.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GridIds.cs" Link="Core\Dispatch\GridIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupIds.cs" Link="Core\Dispatch\GroupIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupSize.cs" Link="Core\Dispatch\GroupSize.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\ThreadIds.cs" Link="Core\Dispatch\ThreadIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GridIds.cs" Link="Core\Dispatch\GridIds.cs" />
<Compile Include="..\ComputeSharp\Core\Exceptions\InvalidExecutionContextException.cs" Link="Core\Exceptions\InvalidExecutionContextException.cs" />
<Compile Include="..\ComputeSharp\Core\Exceptions\MissingMethodSourceException.cs" Link="Core\Exceptions\MissingMethodSourceException.cs" />
<Compile Include="..\ComputeSharp\Core\Extensions\MethodInfoExtensions.cs" Link="Core\Extensions\MethodInfoExtensions.cs" />
+22
ファイルの表示
@@ -249,6 +249,28 @@ namespace ComputeSharp.SourceGenerators.Mappings
}
}
// Programmatically load mappings for the dispatch size
foreach (var property in typeof(DispatchSize).GetProperties(BindingFlags.Static | BindingFlags.Public))
{
string key = $"{typeof(DispatchSize).FullName}{Type.Delimiter}{property.Name}";
switch (property.Name)
{
case nameof(DispatchSize.Count):
knownMembers.Add(key, "__x * __y * __z");
break;
case string name when name.Length == 1:
knownMembers.Add(key, $"__{char.ToLower(name[0])}");
break;
case string name when name.Length == 2:
knownMembers.Add(key, $"int2(__{char.ToLower(name[0])}, __{char.ToLower(name[1])})");
break;
case string name when name.Length == 3:
knownMembers.Add(key, $"int3(__{char.ToLower(name[0])}, __{char.ToLower(name[1])}, __{char.ToLower(name[2])})");
break;
}
}
return knownMembers;
}