Added DispatchSize type
このコミットが含まれているのは:
1 親
b12c5501a8
コミット
1365f963e9
4ファイル変更
+272
-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" />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that indicates the size of the current shader dispatch being executed.
|
||||
/// That is, it enables a shader to access info on the targeted number of invocations along each axis.
|
||||
/// </summary>
|
||||
public static class DispatchSize
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the total number of dispatch invocations being executed.
|
||||
/// </summary>
|
||||
public static int Count => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(Count)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of dispatch invocations being executed on the X axis.
|
||||
/// </summary>
|
||||
public static int X => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(X)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of dispatch invocations being executed on the Y axis.
|
||||
/// </summary>
|
||||
public static int Y => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(Y)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of dispatch invocations being executed on the Z axis.
|
||||
/// </summary>
|
||||
public static int Z => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(Z)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int2 XX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int2 XY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="X"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int2 XZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int2 YX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int2 YY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Y"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int2 YZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Z"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int2 ZX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Z"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int2 ZY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int2"/> value with the components <see cref="Z"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int2 ZZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 XXX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 XXY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="X"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 XXZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 XYX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 XYY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Y"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 XYZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Z"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 XZX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Z"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 XZY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="X"/>, <see cref="Z"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 XZZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(XZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 YXX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 YXY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="X"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 YXZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 YYX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 YYY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Y"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 YYZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Z"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 YZX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Z"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 YZY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Y"/>, <see cref="Z"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 YZZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(YZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="X"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZXX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="X"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZXY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="X"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZXZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Y"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZYX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Y"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZYY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Y"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZYZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Z"/>, <see cref="X"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZZX => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Z"/>, <see cref="Y"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZZY => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Int3"/> value with the components <see cref="Z"/>, <see cref="Z"/>, <see cref="Z"/>.
|
||||
/// </summary>
|
||||
public static Int3 ZZZ => throw new InvalidExecutionContextException($"{typeof(DispatchSize)}.{nameof(ZZZ)}");
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする