Added vector indexers to ThreadIds type
このコミットが含まれているのは:
1 親
af9a391214
コミット
92817af999
5ファイル変更
+188
-11
検索条件に一致するファイルはありません
@@ -5,7 +5,7 @@ namespace ComputeSharp
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that indicates the ids of a given GPU thread running a compute shader.
|
||||
/// </summary>
|
||||
public readonly struct ThreadIds
|
||||
public readonly ref struct ThreadIds
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the X id of the current thread.
|
||||
@@ -21,5 +21,185 @@ namespace ComputeSharp
|
||||
/// Gets the Z id of the current thread.
|
||||
/// </summary>
|
||||
public int Z => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(Z)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> value for all components.
|
||||
/// </summary>
|
||||
public Int2 XX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int2 XY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int2 XZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int2 YX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> value for all components.
|
||||
/// </summary>
|
||||
public Int2 YY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int2 YZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int2 ZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int2 ZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int2"/> value with the <see cref="Z"/> value for all components.
|
||||
/// </summary>
|
||||
public Int2 ZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
|
||||
/// </summary>
|
||||
public Int3 XXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 XXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 XYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 XYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 XYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 XZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 XZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(XZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 YXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 YXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 YXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 YYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
|
||||
/// </summary>
|
||||
public Int3 YYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 YZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 YZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(YZZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZXY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZXZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZYX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZYZ)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZX)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
|
||||
/// </summary>
|
||||
public Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZY)}");
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
|
||||
/// </summary>
|
||||
public Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZZ)}");
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,6 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
{
|
||||
Dictionary<string, string> knownMembers = new()
|
||||
{
|
||||
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.X)}"] = "x",
|
||||
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.Y)}"] = "y",
|
||||
[$"{typeof(ThreadIds).FullName}.{nameof(ThreadIds.Z)}"] = "z",
|
||||
|
||||
[$"{typeof(Vector2).FullName}.{nameof(Vector2.X)}"] = "x",
|
||||
[$"{typeof(Vector2).FullName}.{nameof(Vector2.Y)}"] = "y",
|
||||
[$"{typeof(Vector2).FullName}.{nameof(Vector2.Zero)}"] = "(float2)0",
|
||||
|
||||
@@ -47,14 +47,15 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
/// <summary>
|
||||
/// Gets the known HLSL vector types available as mapped types.
|
||||
/// </summary>
|
||||
public static IReadOnlyCollection<Type> HlslMappedVectorTypes { get; } = new HashSet<Type>(new[]
|
||||
public static IReadOnlyCollection<Type> HlslMappedVectorTypes { get; } = new[]
|
||||
{
|
||||
typeof(ThreadIds),
|
||||
typeof(Bool2), typeof(Bool3), typeof(Bool4),
|
||||
typeof(Int2), typeof(Int3), typeof(Int4),
|
||||
typeof(UInt2), typeof(UInt3), typeof(UInt4),
|
||||
typeof(Float2), typeof(Float3), typeof(Float4),
|
||||
typeof(Double2), typeof(Double3), typeof(Double4)
|
||||
});
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given type name matches a typed resource type.
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
public void Execute(ThreadIds ids)
|
||||
{
|
||||
destination[ids.Y * 32 + ids.X] = source[new(ids.X, ids.Y)];
|
||||
destination[ids.Y * 32 + ids.X] = source[ids.XY];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
public void Execute(ThreadIds ids)
|
||||
{
|
||||
destination[new(ids.X, ids.Y)] = source[new(ids.X, ids.Y)];
|
||||
destination[ids.XY] = source[ids.XY];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
public void Execute(ThreadIds ids)
|
||||
{
|
||||
destination[ids.Z * 32 * 32 + ids.Y * 32 + ids.X] = source[new(ids.X, ids.Y, ids.Z)];
|
||||
destination[ids.Z * 32 * 32 + ids.Y * 32 + ids.X] = source[ids.XYZ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
public void Execute(ThreadIds ids)
|
||||
{
|
||||
destination[new(ids.X, ids.Y, ids.Z)] = source[new(ids.X, ids.Y, ids.Z)];
|
||||
destination[ids.XYZ] = source[ids.XYZ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする