Merge pull request #89 from Sergio0694/feature/group-shared-buffers

Group shared buffers
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2021-01-15 17:35:16 +01:00
コミット 345cd58d19
61ファイル変更
+1295 -243

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

+4 -1
ファイルの表示
@@ -330,4 +330,7 @@ ASALocalRun/
.mfractor/
# Sample images
**/city_*.jpg
samples/**/city_*.jpg
# XML docs files
src/**/ComputeSharp*.xml
+4 -4
ファイルの表示
@@ -92,17 +92,17 @@ namespace ComputeSharp.Benchmark.Blas
public readonly ReadWriteBuffer<float> y;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
int x_offset = ids.X * n * p + ids.Y * m;
int x_offset = ThreadIds.X * n * p + ThreadIds.Y * m;
float result = 0f;
for (int k = 0; k < m; k++)
{
result += x[x_offset + k] * w[k * p + ids.Z];
result += x[x_offset + k] * w[k * p + ThreadIds.Z];
}
y[ids.X * n * p + ids.Y * p + ids.Z] = result + b[ids.Z];
y[ThreadIds.X * n * p + ThreadIds.Y * p + ThreadIds.Z] = result + b[ThreadIds.Z];
}
}
}
+15 -15
ファイルの表示
@@ -302,7 +302,7 @@ namespace ComputeSharp.BokehBlur.Processors
public ReadOnlyBuffer<Complex64> kernel;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
Vector4 real = Vector4.Zero;
Vector4 imaginary = Vector4.Zero;
@@ -313,8 +313,8 @@ namespace ComputeSharp.BokehBlur.Processors
for (int i = 0; i < kernelLength; i++)
{
int offsetY = Hlsl.Clamp(ids.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ids.X, 0, maxX);
int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
Vector4 color = source[offsetX, offsetY];
Complex64 factors = kernel[i];
@@ -322,8 +322,8 @@ namespace ComputeSharp.BokehBlur.Processors
imaginary += factors.Imaginary * color;
}
reals[ids.XY] = real;
imaginaries[ids.XY] = imaginary;
reals[ThreadIds.XY] = real;
imaginaries[ThreadIds.XY] = imaginary;
}
}
@@ -342,7 +342,7 @@ namespace ComputeSharp.BokehBlur.Processors
public ReadOnlyBuffer<Complex64> kernel;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
Vector4 real = Vector4.Zero;
Vector4 imaginary = Vector4.Zero;
@@ -350,11 +350,11 @@ namespace ComputeSharp.BokehBlur.Processors
int maxX = target.Width;
int kernelLength = kernel.Length;
int radiusX = kernelLength >> 1;
int offsetY = Hlsl.Clamp(ids.Y, 0, maxY);
int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
for (int i = 0; i < kernelLength; i++)
{
int offsetX = Hlsl.Clamp(ids.X + i - radiusX, 0, maxX);
int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
Vector4 sourceReal = reals[offsetX, offsetY];
Vector4 sourceImaginary = imaginaries[offsetX, offsetY];
Complex64 factors = kernel[i];
@@ -363,7 +363,7 @@ namespace ComputeSharp.BokehBlur.Processors
imaginary += factors.Real * sourceImaginary + factors.Imaginary * sourceReal;
}
target[ids.XY] += real * z + imaginary * w;
target[ThreadIds.XY] += real * z + imaginary * w;
}
}
@@ -376,17 +376,17 @@ namespace ComputeSharp.BokehBlur.Processors
public readonly IReadWriteTexture2D<Vector4> source;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
int width = source.Width;
for (int i = 0; i < width; i++)
{
Float4 v = source[i, ids.X];
Float4 v = source[i, ThreadIds.X];
v.XYZ = v.XYZ * v.XYZ * v.XYZ;
source[i, ids.X] = v;
source[i, ThreadIds.X] = v;
}
}
}
@@ -401,18 +401,18 @@ namespace ComputeSharp.BokehBlur.Processors
public readonly IReadWriteTexture2D<Vector4> target;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
int width = source.Width;
for (int i = 0; i < width; i++)
{
Float4 v = source[i, ids.X];
Float4 v = source[i, ThreadIds.X];
v.XYZ = Hlsl.Clamp(v.XYZ, 0, float.MaxValue);
v.XYZ = Hlsl.Pow(v.XYZ, 1 / 3f);
target[i, ids.X] = v;
target[i, ThreadIds.X] = v;
}
}
}
+8 -8
ファイルの表示
@@ -115,7 +115,7 @@ namespace ComputeSharp.BokehBlur.Processors
public readonly ReadOnlyBuffer<float> kernel;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
Vector4 result = Vector4.Zero;
int maxY = source.Height - 1;
@@ -125,14 +125,14 @@ namespace ComputeSharp.BokehBlur.Processors
for (int i = 0; i < kernelLength; i++)
{
int offsetY = Hlsl.Clamp(ids.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ids.X, 0, maxX);
int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
Vector4 color = source[offsetX, offsetY];
result += kernel[i] * color;
}
target[ids.XY] = result;
target[ThreadIds.XY] = result;
}
}
@@ -147,24 +147,24 @@ namespace ComputeSharp.BokehBlur.Processors
public readonly ReadOnlyBuffer<float> kernel;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
Vector4 result = Vector4.Zero;
int maxY = source.Height - 1;
int maxX = source.Width - 1;
int kernelLength = kernel.Length;
int radiusX = kernelLength >> 1;
int offsetY = Hlsl.Clamp(ids.Y, 0, maxY);
int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
for (int i = 0; i < kernelLength; i++)
{
int offsetX = Hlsl.Clamp(ids.X + i - radiusX, 0, maxX);
int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
Vector4 color = source[offsetX, offsetY];
result += kernel[i] * color;
}
target[ids.XY] = result;
target[ThreadIds.XY] = result;
}
}
}
+2 -2
ファイルの表示
@@ -47,9 +47,9 @@ namespace ComputeSharp.Sample
public readonly ReadWriteBuffer<float> buffer;
/// <inheritdoc/>
public void Execute(ThreadIds ids)
public void Execute()
{
buffer[ids.X] *= 2;
buffer[ThreadIds.X] *= 2;
}
}
+1 -1
ファイルの表示
@@ -5,7 +5,7 @@ namespace ComputeSharp
/// <summary>
/// An attribute that indicates that a target shader type should get an automatic constructor for all fields.
/// </summary>
[AttributeUsage(AttributeTargets.Struct)]
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class AutoConstructorAttribute : Attribute
{
}
+46
ファイルの表示
@@ -0,0 +1,46 @@
using System;
namespace ComputeSharp
{
/// <summary>
/// An attribute that indicates that an array static field in a shader type will be shared in a thread group.
/// <para>
/// This attribute can be used to declare fields as follows:
/// <code>
/// struct MyShader : IComputeShader
/// {
/// [GroupShared(32)]
/// static float[] MyBuffer;
/// }
/// </code>
/// </para>
/// The buffer shouldn't be manually initialized, as each shader invocation will automatically receive the
/// right buffer in use for the thread group it belongs to. If there is an assignment for the field, it
/// will just be ignored in the shader. Additionally, buffer types are not allowed as array items.
/// </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public sealed class GroupSharedAttribute : Attribute
{
/// <summary>
/// Creates a new <see cref="GroupSharedAttribute"/> instance with the specified parameters.
/// </summary>
public GroupSharedAttribute()
{
}
/// <summary>
/// Creates a new <see cref="GroupSharedAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="size">The size of the shared buffer to declare.</param>
public GroupSharedAttribute(int size)
{
Size = size;
}
/// <summary>
/// Gets the size of the shared buffer being declared.
/// If <see langword="null"/>, the thread group size will be used.
/// </summary>
public int? Size { get; }
}
}
+1 -1
ファイルの表示
@@ -9,7 +9,7 @@ namespace ComputeSharp
/// correctly, wrapped methods need to have this attribute manually applied to them.
/// Methods also need to be static, though this can only be tested at runtime.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ShaderMethodAttribute : Attribute
{
}
+9 -1
ファイルの表示
@@ -25,13 +25,15 @@ namespace ComputeSharp.__Internals
/// <param name="executeMethod">The source code for the <see cref="IComputeShader.Execute"/> method.</param>
/// <param name="methods">The collection of processed methods.</param>
/// <param name="constants">The collection of discovered constants.</param>
/// <param name="sharedBuffers">The collection of group shared buffers</param>
public IComputeShaderSourceAttribute(
string shaderTypeName,
string[] types,
object[] args,
string executeMethod,
string[] methods,
object[] constants)
object[] constants,
object[] sharedBuffers)
{
ShaderTypeName = shaderTypeName;
Types = types;
@@ -39,6 +41,7 @@ namespace ComputeSharp.__Internals
ExecuteMethod = executeMethod;
Methods = methods;
Constants = constants.Cast<string[]>().ToDictionary(static c => c[0], static c => c[1]);
SharedBuffers = sharedBuffers.Cast<object[]>().ToDictionary(static t => (string)t[0], static t => ((string)t[1], (int?)t[2]));
}
/// <summary>
@@ -71,6 +74,11 @@ namespace ComputeSharp.__Internals
/// </summary>
internal IReadOnlyDictionary<string, string> Constants { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
internal IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; }
/// <summary>
/// Gets the associated <see cref="IComputeShaderSourceAttribute"/> instance for a specified type.
/// </summary>
+3 -3
ファイルの表示
@@ -79,10 +79,10 @@ namespace ComputeSharp.__Internals
}
/// <summary>
/// Gets the associated <see cref="ShaderMethodSourceAttribute"/> instance for a specified type.
/// Gets the associated <see cref="ShaderMethodSourceAttribute"/> instance for a specified delegate.
/// </summary>
/// <typeparam name="T">The shader type to get the attribute for.</typeparam>
/// <returns>The associated <see cref="IComputeShaderSourceAttribute"/> instance for type <typeparamref name="T"/>.</returns>
/// <param name="function">The input <see cref="Delegate"/> instance to get info for.</param>
/// <returns>The associated <see cref="ShaderMethodSourceAttribute"/> instance for the given delegate.</returns>
[Pure]
internal static ShaderMethodSourceAttribute GetForDelegate(Delegate function)
{
+2
ファイルの表示
@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.Core.xml</DocumentationFile>
</PropertyGroup>
<!-- .NET Standard 2.0 doesn't have the vector types -->
+210
ファイルの表示
@@ -0,0 +1,210 @@
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that indicates the ids of a given GPU thread running a compute shader within a dispatch group.
/// </summary>
public static class GroupIds
{
/// <summary>
/// Gets the flattened index of the current thread with respect to the dispatch group.
/// </summary>
public static int Index => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(Index)}");
/// <summary>
/// Gets the X id of the current thread with respect to the dispatch group.
/// </summary>
public static int X => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(X)}");
/// <summary>
/// Gets the Y id of the current thread with respect to the dispatch group.
/// </summary>
public static int Y => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(Y)}");
/// <summary>
/// Gets the Z id of the current thread with respect to the dispatch group.
/// </summary>
public static int Z => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(Z)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int2 XX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 XY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 XZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int2 YX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YX)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int2 YY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 YZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int2 ZX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 ZY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZY)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int2 ZZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int3 XXX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XXY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XYX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XYY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 XYZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XZX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 XZY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YXX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YXY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 YXZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YYX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int3 YYY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 YZX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YZY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 ZXY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{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 static Int3 ZYX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(GroupIds)}.{nameof(ZZZ)}");
}
}
+210
ファイルの表示
@@ -0,0 +1,210 @@
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that indicates the size info of a given GPU thread group running a compute shader within.
/// </summary>
public static class GroupSize
{
/// <summary>
/// Gets the total size of the current thread group.
/// </summary>
public static int Count => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(Count)}");
/// <summary>
/// Gets the size of the X axis of the current thread group.
/// </summary>
public static int X => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(X)}");
/// <summary>
/// Gets the size of the Y axis of the current thread group.
/// </summary>
public static int Y => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(Y)}");
/// <summary>
/// Gets the size of the Z axis of the current thread group.
/// </summary>
public static int Z => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(Z)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int2 XX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 XY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 XZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int2 YX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YX)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int2 YY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 YZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int2 ZX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 ZY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZY)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int2 ZZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int3 XXX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XXY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XYX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XYY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 XYZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XZX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 XZY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YXX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YXY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 YXZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YYX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int3 YYY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 YZX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YZY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 ZXY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{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 static Int3 ZYX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(GroupSize)}.{nameof(ZZZ)}");
}
}
@@ -3,203 +3,203 @@
namespace ComputeSharp
{
/// <summary>
/// A <see langword="struct"/> that indicates the ids of a given GPU thread running a compute shader.
/// A <see langword="class"/> that indicates the ids of a given GPU thread running a compute shader.
/// </summary>
public readonly ref struct ThreadIds
public static class ThreadIds
{
/// <summary>
/// Gets the X id of the current thread.
/// </summary>
public int X => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(X)}");
public static int X => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(X)}");
/// <summary>
/// Gets the Y id of the current thread.
/// </summary>
public int Y => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(Y)}");
public static int Y => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(Y)}");
/// <summary>
/// Gets the Z id of the current thread.
/// </summary>
public int Z => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(Z)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static 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)}");
public static Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(ThreadIds)}.{nameof(ZZZ)}");
}
}
+205
ファイルの表示
@@ -0,0 +1,205 @@
using ComputeSharp.Exceptions;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that indicates the ids of a given dispatch warp (a group of threads).
/// </summary>
public static class WarpIds
{
/// <summary>
/// Gets the X id of the current thread with respect to the dispatch group.
/// </summary>
public static int X => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(X)}");
/// <summary>
/// Gets the Y id of the current thread with respect to the dispatch group.
/// </summary>
public static int Y => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(Y)}");
/// <summary>
/// Gets the Z id of the current thread with respect to the dispatch group.
/// </summary>
public static int Z => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(Z)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int2 XX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 XY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 XZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int2 YX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YX)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int2 YY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YY)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int2 YZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YZ)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int2 ZX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZX)}");
/// <summary>
/// Gets or sets an <see cref="Int2"/> value with the <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int2 ZY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZY)}");
/// <summary>
/// Gets an <see cref="Int2"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int2 ZZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/> value for all components.
/// </summary>
public static Int3 XXX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XXY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XXZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XYX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 XYY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 XYZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 XZX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 XZY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="X"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 XZZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(XZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YXX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YXX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="X"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YXY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 YXZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YXZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="X"/> values.
/// </summary>
public static Int3 YYX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/> value for all components.
/// </summary>
public static Int3 YYY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YYZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 YZX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 YZY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Y"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 YZZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(YZZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 ZXY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZXY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="X"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZXZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{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 static Int3 ZYX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZYX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZYY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZYY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Y"/> and <see cref="Z"/> values.
/// </summary>
public static Int3 ZYZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZYZ)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="X"/> values.
/// </summary>
public static Int3 ZZX => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZZX)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/>, <see cref="Z"/> and <see cref="Y"/> values.
/// </summary>
public static Int3 ZZY => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZZY)}");
/// <summary>
/// Gets an <see cref="Int3"/> value with the <see cref="Z"/> value for all components.
/// </summary>
public static Int3 ZZZ => throw new InvalidExecutionContextException($"{nameof(WarpIds)}.{nameof(ZZZ)}");
}
}
+1 -2
ファイルの表示
@@ -8,7 +8,6 @@
/// <summary>
/// Executes the current compute shader.
/// </summary>
/// <param name="ids">The <see cref="ThreadIds"/> value with the current execution indices.</param>
void Execute(ThreadIds ids);
void Execute();
}
}
+46
ファイルの表示
@@ -153,6 +153,28 @@ namespace ComputeSharp
[Pure]
public static bool All(Float4 x) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(All)}({nameof(Float4)})");
/// <summary>
/// Blocks execution of all threads in a group until all memory accesses have been completed.
/// </summary>
/// <remarks>
/// A memory barrier guarantees that outstanding memory operations have completed.
/// Threads are synchronized at GroupSync barriers.
/// This may stall a thread or threads if memory operations are in progress.
/// </remarks>
[PreserveMemberName]
public static void AllMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(AllMemoryBarrier)}()");
/// <summary>
/// Blocks execution of all threads in a group until all memory accesses have been completed and all threads in the group have reached this call.
/// </summary>
/// <remarks>
/// A memory barrier guarantees that outstanding memory operations have completed.
/// Threads are synchronized at GroupSync barriers.
/// This may stall a thread or threads if memory operations are in progress.
/// </remarks>
[PreserveMemberName]
public static void AllMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(AllMemoryBarrierWithGroupSync)}()");
/// <summary>
/// Determines if any components of the specified value are non-zero.
/// </summary>
@@ -616,6 +638,18 @@ namespace ComputeSharp
[Pure]
public static Float3 Degrees(Float4 x) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(Degrees)}({nameof(Float4)})");
/// <summary>
/// Blocks execution of all threads in a group until all device memory accesses have been completed.
/// </summary>
[PreserveMemberName]
public static void DeviceMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(DeviceMemoryBarrier)}()");
/// <summary>
/// Blocks execution of all threads in a group until all device memory accesses have been completed and all threads in the group have reached this call.
/// </summary>
[PreserveMemberName]
public static void DeviceMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(DeviceMemoryBarrierWithGroupSync)}()");
/// <summary>
/// Returns a distance scalar between two <see cref="Float2"/> values.
/// </summary>
@@ -870,6 +904,18 @@ namespace ComputeSharp
[Pure]
public static Float4 Frexp(Float4 x, out Float4 exp) => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(Frexp)}({nameof(Float4)},{nameof(Float4)})");
/// <summary>
/// Blocks execution of all threads in a group until all group shared accesses have been completed.
/// </summary>
[PreserveMemberName]
public static void GroupMemoryBarrier() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(GroupMemoryBarrier)}()");
/// <summary>
/// Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call.
/// </summary>
[PreserveMemberName]
public static void GroupMemoryBarrierWithGroupSync() => throw new InvalidExecutionContextException($"{nameof(Hlsl)}.{nameof(GroupMemoryBarrierWithGroupSync)}()");
/// <summary>
/// Performs a guaranteed atomic add of a value to a destination.
/// </summary>
+2 -2
ファイルの表示
@@ -30,8 +30,8 @@ namespace ComputeSharp
/// <summary>
/// Initializes a new instance of the <see cref="Rg16"/> struct.
/// </summary>
/// <param name="x">The x-component</param>
/// <param name="y">The y-component</param>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
public Rg16(byte r, byte g)
{
R = r;
+2 -2
ファイルの表示
@@ -30,8 +30,8 @@ namespace ComputeSharp
/// <summary>
/// Initializes a new instance of the <see cref="Rg32"/> struct.
/// </summary>
/// <param name="x">The x-component</param>
/// <param name="y">The y-component</param>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
public Rg32(ushort r, ushort g)
{
R = r;
+2 -2
ファイルの表示
@@ -567,13 +567,13 @@ namespace ComputeSharp
/// <summary>
/// Casts a <see cref="Float3"/> value to a <see cref="Vector3"/> one.
/// </summary>
/// <param name="xy">The input <see cref="Float3"/> value to cast.</param>
/// <param name="xyz">The input <see cref="Float3"/> value to cast.</param>
public static unsafe implicit operator Vector3(Float3 xyz) => *(Vector3*)&xyz;
/// <summary>
/// Casts a <see cref="Vector3"/> value to a <see cref="Float3"/> one.
/// </summary>
/// <param name="xy">The input <see cref="Vector3"/> value to cast.</param>
/// <param name="xyz">The input <see cref="Vector3"/> value to cast.</param>
public static unsafe implicit operator Float3(Vector3 xyz) => *(Float3*)&xyz;
/// <summary>
+2 -2
ファイルの表示
@@ -3972,13 +3972,13 @@ namespace ComputeSharp
/// <summary>
/// Casts a <see cref="Float4"/> value to a <see cref="Vector4"/> one.
/// </summary>
/// <param name="xy">The input <see cref="Float4"/> value to cast.</param>
/// <param name="xyzw">The input <see cref="Float4"/> value to cast.</param>
public static unsafe implicit operator Vector4(Float4 xyzw) => *(Vector4*)&xyzw;
/// <summary>
/// Casts a <see cref="Vector4"/> value to a <see cref="Float4"/> one.
/// </summary>
/// <param name="xy">The input <see cref="Vector4"/> value to cast.</param>
/// <param name="xyzw">The input <see cref="Vector4"/> value to cast.</param>
public static unsafe implicit operator Float4(Vector4 xyzw) => *(Float4*)&xyzw;
/// <summary>
+2 -1
ファイルの表示
@@ -120,6 +120,7 @@ namespace ComputeSharp.Graphics.Commands
/// <param name="d3D12ResourceSource">The source <see cref="ID3D12Resource"/> (a texture) to read from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to read from.</param>
/// <param name="height">The height of the memory area to read from.</param>
/// <param name="depth">The depth of the memory area to read from.</param>
@@ -166,7 +167,7 @@ namespace ComputeSharp.Graphics.Commands
/// <summary>
/// Sets a given <see cref="PipelineData"/> object ready to be executed.
/// </summary>
/// <param name="pipelineState">The input <see cref="PipelineData"/> to setup.</param>
/// <param name="pipelineData">The input <see cref="PipelineData"/> to setup.</param>
public readonly void SetPipelineData(PipelineData pipelineData)
{
this.d3D12GraphicsCommandList.Get()->SetComputeRootSignature(pipelineData.D3D12RootSignature);
+2 -2
ファイルの表示
@@ -79,7 +79,7 @@ namespace ComputeSharp.Graphics.Commands.Interop
/// Rents a new CPU and GPU handle pair to use in a memory buffer.
/// </summary>
/// <param name="d3D12CpuDescriptorHandle">The resulting <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12CpuDescriptorHandle">The resulting <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12GpuDescriptorHandle">The resulting <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
public void Rent(
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
@@ -106,7 +106,7 @@ namespace ComputeSharp.Graphics.Commands.Interop
/// Returns a CPU and GPU handle pair for later use.
/// </summary>
/// <param name="d3D12CpuDescriptorHandle">The returned <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12CpuDescriptorHandle">The returned <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
/// <param name="d3D12GpuDescriptorHandle">The returned <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value.</param>
public void Return(
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
+3 -4
ファイルの表示
@@ -19,11 +19,10 @@ namespace ComputeSharp.Graphics.Commands
private ComPtr<ID3D12PipelineState> d3D12PipelineState;
/// <summary>
/// Creates a new <see cref="PipelineState"/> instance with the specified parameters.
/// Creates a new <see cref="PipelineData"/> instance with the specified parameters.
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> to use.</param>
/// <param name="rootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader.</param>
/// <param name="computeShader">The bytecode for the compute shader to run.</param>
/// <param name="d3D12RootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader.</param>
/// <param name="d3D12PipelineState">The compiled pipeline state to reuse for the current shader.</param>
public PipelineData(ComPtr<ID3D12RootSignature> d3D12RootSignature, ComPtr<ID3D12PipelineState> d3D12PipelineState)
{
this.d3D12RootSignature = d3D12RootSignature;
+4 -2
ファイルの表示
@@ -2,11 +2,13 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.Graphics.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit" Version="7.0.0-preview4" />
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.19041-beta2" />
<PackageReference Include="Microsoft.Toolkit" Version="7.0.0-preview4" />
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.19041-beta2" />
</ItemGroup>
<ItemGroup>
+1
ファイルの表示
@@ -423,6 +423,7 @@ namespace ComputeSharp.Graphics.Extensions
/// </summary>
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the command list.</param>
/// <param name="d3D12CommandListType">The type of command list to create.</param>
/// <param name="d3D12CommandAllocator">The command allocator to use to create the command list.</param>
/// <returns>A pointer to the newly allocated <see cref="ID3D12GraphicsCommandList"/> instance.</returns>
/// <exception cref="Exception">Thrown when the creation of the command list fails.</exception>
public static ComPtr<ID3D12GraphicsCommandList> CreateCommandList(
+5 -5
ファイルの表示
@@ -152,11 +152,11 @@ namespace ComputeSharp
internal bool IsCacheCoherentUMA { get; }
/// <summary>
/// Checks whether the current device supports the creation of <see cref="Buffers.Abstract.Texture2D{T}"/>
/// Checks whether the current device supports the creation of <see cref="Resources.Texture2D{T}"/>
/// resources for a specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of values to check support for.</typeparam>
/// <returns>Whether <see cref="Buffers.Abstract.Texture2D{T}"/> instances can be created by the current device.</returns>
/// <returns>Whether <see cref="Resources.Texture2D{T}"/> instances can be created by the current device.</returns>
[Pure]
public bool IsTexture2DSupportedForType<T>()
where T : unmanaged
@@ -167,11 +167,11 @@ namespace ComputeSharp
}
/// <summary>
/// Checks whether the current device supports the creation of <see cref="Buffers.Abstract.Texture3D{T}"/>
/// Checks whether the current device supports the creation of <see cref="Resources.Texture3D{T}"/>
/// resources for a specified type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of values to check support for.</typeparam>
/// <returns>Whether <see cref="Buffers.Abstract.Texture3D{T}"/> instances can be created by the current device.</returns>
/// <returns>Whether <see cref="Resources.Texture3D{T}"/> instances can be created by the current device.</returns>
[Pure]
public bool IsTexture3DSupportedForType<T>()
where T : unmanaged
@@ -181,7 +181,7 @@ namespace ComputeSharp
return this.d3D12Device.Get()->IsDxgiFormatSupported(DXGIFormatHelper.GetForType<T>(), D3D12_FORMAT_SUPPORT1_TEXTURE3D);
}
/// <inheritdoc cref="ID3D12DescriptorHandleAllocator.Allocate"/>
/// <inheritdoc cref="ID3D12DescriptorHandleAllocator.Rent"/>
internal void RentShaderResourceViewDescriptorHandles(
out D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
out D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle)
+1 -1
ファイルの表示
@@ -11,7 +11,7 @@ namespace ComputeSharp
/// <summary>
/// Creates a new <see cref="GraphicsDeviceInfo"/> instance with the specified parameters.
/// </summary>
/// <param name="description">The available info for the associate device.</param>
/// <param name="dxgiDescription1">The available info for the associated device.</param>
internal unsafe GraphicsDeviceInfo(DXGI_ADAPTER_DESC1* dxgiDescription1)
{
Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid);
-2
ファイルの表示
@@ -174,7 +174,6 @@ namespace ComputeSharp.Graphics.Helpers
/// Copies the content of a source memory area to the 3D area pointed by an input pointer.
/// The destination memory area has padding in each row, while the source does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The source memory area to read from.</param>
/// <param name="destination">The pointer that indicates the 3D memory area to write to.</param>
/// <param name="height">The height of the 3D memory area to write to.</param>
@@ -219,7 +218,6 @@ namespace ComputeSharp.Graphics.Helpers
/// Copies a 3D memory area pointed by a pointer value to a target memory area.
/// The source memory area has padding in each row, while the target does not.
/// </summary>
/// <typeparam name="T">The type of values to read.</typeparam>
/// <param name="source">The pointer that indicates the memory area to read from.</param>
/// <param name="height">The height of the 3D memory area to read.</param>
/// <param name="depth">The depth of the 3D memory area to read.</param>
+1 -1
ファイルの表示
@@ -28,7 +28,7 @@
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <param name="y">The depthwise offset of the value to get.</param>
/// <param name="z">The depthwise offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public TPixel this[int x, int y, int z] { get; }
+1 -1
ファイルの表示
@@ -32,7 +32,7 @@ namespace ComputeSharp
/// </summary>
/// <param name="x">The horizontal offset of the value to get.</param>
/// <param name="y">The vertical offset of the value to get.</param>
/// <param name="y">The depthwise offset of the value to get.</param>
/// <param name="z">The depthwise offset of the value to get.</param>
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
public T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D<T>)}<T>[int,int,int]");
+2
ファイルの表示
@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.Shaders.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
+29 -10
ファイルの表示
@@ -33,7 +33,16 @@ namespace ComputeSharp.Shaders.Renderer
builder.AppendLine("// This shader was created by ComputeSharp.");
builder.AppendLine("// See: https://github.com/Sergio0694/ComputeSharp.");
// Constants
// Group size constants
builder.AppendLine();
builder.Append("#define __GroupSize__get_X ");
builder.AppendLine(threadsX.ToString());
builder.Append("#define __GroupSize__get_Y ");
builder.AppendLine(threadsY.ToString());
builder.Append("#define __GroupSize__get_Z ");
builder.AppendLine(threadsZ.ToString());
// User defined onstants
if (info.ConstantsInfo.Count > 0)
{
builder.AppendLine();
@@ -114,6 +123,22 @@ namespace ComputeSharp.Shaders.Renderer
}
}
// Shared buffers
foreach (var buffer in info.SharedBuffers)
{
builder.AppendLine();
builder.Append("groupshared ");
builder.Append(buffer.Value.Type);
builder.Append(' ');
builder.Append(buffer.Key);
builder.Append('[');
if (buffer.Value.Count is int count) builder.Append(count.ToString());
else builder.Append((threadsX * threadsY * threadsZ).ToString());
builder.AppendLine("];");
}
// Captured methods
foreach (var function in info.MethodsInfo)
{
@@ -123,13 +148,7 @@ namespace ComputeSharp.Shaders.Renderer
// Entry point
builder.AppendLine();
builder.Append("[NumThreads(");
builder.Append(threadsX.ToString());
builder.Append(", ");
builder.Append(threadsY.ToString());
builder.Append(", ");
builder.Append(threadsZ.ToString());
builder.AppendLine(")]");
builder.AppendLine("[NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)]");
builder.AppendLine(info.EntryPoint);
return builder;
@@ -235,7 +254,7 @@ namespace ComputeSharp.Shaders.Renderer
/// <summary>
/// Ensures that <see cref="array"/> has enough free space to contain a given number of new items.
/// </summary>
/// <param name="sizeHint">The minimum number of items to ensure space for in <see cref="array"/>.</param>
/// <param name="requestedSize">The minimum number of items to ensure space for in <see cref="array"/>.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void EnsureCapacity(int requestedSize)
{
@@ -281,7 +300,7 @@ namespace ComputeSharp.Shaders.Renderer
internal sealed class DebugView
{
/// <summary>
/// Initializes a new instance of the <see cref="DebugView{T}"/> class with the specified parameters.
/// Initializes a new instance of the <see cref="DebugView"/> class with the specified parameters.
/// </summary>
/// <param name="builder">The input <see cref="ArrayPoolStringBuilder"/> instance to display.</param>
public DebugView(ArrayPoolStringBuilder builder)
+1
ファイルの表示
@@ -5,6 +5,7 @@
/// </summary>
/// <param name="FieldType">The type of the current field in the HLSL shader.</param>
/// <param name="FieldName">The name to use for the current field.</param>
/// <param name="BufferIndex">The register index to bind the resource to.</param>
internal abstract record HlslResourceInfo(string FieldType, string FieldName, int BufferIndex)
: CapturedFieldInfo(FieldType, FieldName)
{
+11 -6
ファイルの表示
@@ -11,31 +11,36 @@ namespace ComputeSharp.Shaders.Translation
/// <summary>
/// Gets the generated source code for the method in the current shader.
/// </summary>
public string EntryPoint { get; }
string EntryPoint { get; }
/// <summary>
/// Gets the collection of <see cref="Renderer.Models.HlslResourceInfo"/> items for the shader fields.
/// </summary>
public IReadOnlyList<HlslResourceInfo> HlslResourceInfo { get; }
IReadOnlyList<HlslResourceInfo> HlslResourceInfo { get; }
/// <summary>
/// Gets the collection of <see cref="CapturedFieldInfo"/> items for the shader fields.
/// </summary>
public IReadOnlyList<CapturedFieldInfo> FieldsInfo { get; }
IReadOnlyList<CapturedFieldInfo> FieldsInfo { get; }
/// <summary>
/// Gets the collection of methods to be used in the shader.
/// </summary>
public IReadOnlyCollection<string> MethodsInfo { get; }
IReadOnlyCollection<string> MethodsInfo { get; }
/// <summary>
/// Gets the collection of constants to be declared in the shader.
/// </summary>
public IReadOnlyDictionary<string, string> ConstantsInfo { get; }
IReadOnlyDictionary<string, string> ConstantsInfo { get; }
/// <summary>
/// Gets the collection of declared types for the shader.
/// </summary>
public IReadOnlyCollection<string> DeclaredTypes { get; }
IReadOnlyCollection<string> DeclaredTypes { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; }
}
}
+6 -2
ファイルの表示
@@ -104,11 +104,14 @@ namespace ComputeSharp.Shaders.Translation
/// <inheritdoc/>
public IReadOnlyCollection<string> DeclaredTypes => this.declaredTypes;
/// <inheritdoc/>
public IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; private set; }
/// <summary>
/// Loads and processes an input<typeparamref name="T"/> shadeer.
/// </summary>
/// <param name="shader">The <typeparamref name="T"/> instance to use to build the shader.</param>
/// <returns>A new <see cref="ShaderLoader"/> instance representing the input shader.</returns>
/// <returns>A new <see cref="ShaderLoader{T}"/> instance representing the input shader.</returns>
[Pure]
public static ShaderLoader<T> Load(in T shader)
{
@@ -131,6 +134,7 @@ namespace ComputeSharp.Shaders.Translation
private void LoadMethodMetadata()
{
EntryPoint = Attribute.ExecuteMethod;
SharedBuffers = Attribute.SharedBuffers;
this.declaredTypes.AddRange(Attribute.Types);
this.methodsInfo.AddRange(Attribute.Methods);
@@ -175,7 +179,7 @@ namespace ComputeSharp.Shaders.Translation
}
/// <summary>
/// Loads a specified <see cref="ReadableMember"/> and adds it to the shader model.
/// Loads a specified <see cref="FieldInfo"/> and adds it to the shader model.
/// </summary>
/// <param name="shader">The boxed <typeparamref name="T"/> instance to use to build the shader.</param>
/// <param name="fieldInfo">The target <see cref="FieldInfo"/> to load.</param>
+1 -1
ファイルの表示
@@ -43,7 +43,7 @@ namespace ComputeSharp.SourceGenerators
var structModifiers = structDeclaration.Modifiers;
var fields = (
from fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>()
where !fieldSymbol.IsConst
where !fieldSymbol.IsConst && !fieldSymbol.IsStatic
let typeName = fieldSymbol.Type!.ToDisplayString()
let fieldFullType = ParseTypeName(typeName)
select (Type: fieldFullType, Identifier: Identifier(fieldSymbol.Name))).ToImmutableArray();
+5 -1
ファイルの表示
@@ -14,9 +14,14 @@
and to match members based on full name, so the types being in the generator assembly are not an issue.-->
<ItemGroup>
<Compile Include="..\ComputeSharp.Core\Attributes\AutoConstructorAttribute.cs" Link="Core\Attributes\AutoConstructorAttribute.cs" />
<Compile Include="..\ComputeSharp.Core\Attributes\GroupSharedAttribute.cs" Link="Core\Attributes\GroupSharedAttribute.cs" />
<Compile Include="..\ComputeSharp.Core\Attributes\ShaderMethodAttribute.cs" Link="Core\Attributes\ShaderMethodAttribute.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\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\WarpIds.cs" Link="Core\Dispatch\WarpIds.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" />
@@ -37,7 +42,6 @@
<Compile Include="..\ComputeSharp.Core\Primitives\Int\Int2.cs" Link="Core\Primitives\Int\Int2.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\Int\Int3.cs" Link="Core\Primitives\Int\Int3.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\Int\Int4.cs" Link="Core\Primitives\Int\Int4.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\ThreadIds.cs" Link="Core\Primitives\ThreadIds.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\UInt\UInt2.cs" Link="Core\Primitives\UInt\UInt2.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\UInt\UInt3.cs" Link="Core\Primitives\UInt\UInt3.cs" />
<Compile Include="..\ComputeSharp.Core\Primitives\UInt\UInt4.cs" Link="Core\Primitives\UInt\UInt4.cs" />
+32
ファイルの表示
@@ -57,5 +57,37 @@ namespace ComputeSharp.SourceGenerators.Helpers
ImplicitArrayCreationExpression(InitializerExpression(SyntaxKind.ArrayInitializerExpression).AddExpressions(
group.Select(static item => LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(item))).ToArray()))).ToArray()));
}
/// <summary>
/// Creates an <see cref="object"/>[] array expression with the nested groups in the input sequence.
/// <para>
/// That it, it applies the following transformation:
/// <code>
/// { ("K1", "V1", I1), ("K2", "V2", null) } => new object[] { new object[] { "K1", "V1", I1 }, new object[] { "K2", "V2", null } }
/// </code>
/// </para>
/// </summary>
/// <param name="values">The input sequence of <see cref="string"/> groups.</param>
/// <returns>An <see cref="ArrayCreationExpression"/> instance with the described contents.</returns>
[Pure]
public static ArrayCreationExpressionSyntax NestedArrayExpression(IEnumerable<(string A, string B, int? C)> groups)
{
return
ArrayCreationExpression(
ArrayType(PredefinedType(Token(SyntaxKind.ObjectKeyword)))
.AddRankSpecifiers(ArrayRankSpecifier(SingletonSeparatedList<ExpressionSyntax>(OmittedArraySizeExpression()))))
.WithInitializer(InitializerExpression(SyntaxKind.ArrayInitializerExpression)
.AddExpressions(groups.Select(static group =>
ArrayCreationExpression(
ArrayType(PredefinedType(Token(SyntaxKind.ObjectKeyword)))
.AddRankSpecifiers(ArrayRankSpecifier(SingletonSeparatedList<ExpressionSyntax>(OmittedArraySizeExpression()))))
.WithInitializer(InitializerExpression(SyntaxKind.ArrayInitializerExpression)
.AddExpressions(
LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(group.A)),
LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(group.B)),
group.C is int i
? LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i))
: LiteralExpression(SyntaxKind.NullLiteralExpression)))).ToArray()));
}
}
}
+2
ファイルの表示
@@ -128,6 +128,8 @@ namespace ComputeSharp.SourceGenerators
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic) continue;
INamedTypeSymbol typeSymbol = (INamedTypeSymbol)fieldSymbol.Type;
string typeName = typeSymbol.GetFullMetadataName();
+2
ファイルの表示
@@ -120,6 +120,8 @@ namespace ComputeSharp.SourceGenerators
{
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic) continue;
INamedTypeSymbol typeSymbol = (INamedTypeSymbol)fieldSymbol.Type;
if (typeSymbol.TypeKind != TypeKind.Delegate) continue;
+35 -7
ファイルの表示
@@ -50,6 +50,7 @@ namespace ComputeSharp.SourceGenerators
// Explore the syntax tree and extract the processed info
var processedMembers = GetProcessedMembers(structDeclarationSymbol, discoveredTypes).ToArray();
var sharedBuffers = GetGroupSharedMembers(structDeclarationSymbol, discoveredTypes).ToArray();
var (entryPoint, localFunctions) = GetProcessedMethods(structDeclaration, structDeclarationSymbol, semanticModel, discoveredTypes, staticMethods, constantDefinitions);
var processedTypes = GetProcessedTypes(discoveredTypes).ToArray();
var processedMethods = localFunctions.Concat(staticMethods.Values).Select(static method => method.NormalizeWhitespace().ToFullString()).ToArray();
@@ -66,7 +67,8 @@ namespace ComputeSharp.SourceGenerators
AttributeArgument(NestedArrayExpression(processedMembers)),
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(entryPoint))),
AttributeArgument(ArrayExpression(processedMethods)),
AttributeArgument(NestedArrayExpression(processedConstants)))))
AttributeArgument(NestedArrayExpression(processedConstants)),
AttributeArgument(NestedArrayExpression(sharedBuffers)))))
.WithOpenBracketToken(Token(TriviaList(Trivia(PragmaWarningDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true))), SyntaxKind.OpenBracketToken, TriviaList()))
.WithTarget(AttributeTargetSpecifier(Token(SyntaxKind.AssemblyKeyword))))
.NormalizeWhitespace()
@@ -88,6 +90,8 @@ namespace ComputeSharp.SourceGenerators
{
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic) continue;
INamedTypeSymbol typeSymbol = (INamedTypeSymbol)fieldSymbol.Type;
string typeName = HlslKnownTypes.GetMappedName(typeSymbol);
@@ -106,6 +110,33 @@ namespace ComputeSharp.SourceGenerators
}
}
/// <summary>
/// Gets a sequence of captured members and their mapped names.
/// </summary>
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
/// <param name="types">The collection of currently discovered types.</param>
/// <returns>A sequence of captured members in <paramref name="structDeclarationSymbol"/>.</returns>
[Pure]
private static IEnumerable<(string Name, string Type, int? Count)> GetGroupSharedMembers(INamedTypeSymbol structDeclarationSymbol, ICollection<INamedTypeSymbol> types)
{
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (!fieldSymbol.IsStatic) continue;
AttributeData attribute = fieldSymbol.GetAttributes().First(static a => a.AttributeClass is { Name: nameof(GroupSharedAttribute) });
int? bufferSize = (int?)attribute.ConstructorArguments.FirstOrDefault().Value;
IArrayTypeSymbol typeSymbol = (IArrayTypeSymbol)fieldSymbol.Type;
string typeName = HlslKnownTypes.GetMappedElementName(typeSymbol);
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);
yield return (mapping ?? fieldSymbol.Name, typeName, bufferSize);
types.Add((INamedTypeSymbol)typeSymbol.ElementType);
}
}
/// <summary>
/// Gets a sequence of processed methods declared within a given type.
/// </summary>
@@ -140,18 +171,15 @@ namespace ComputeSharp.SourceGenerators
ShaderSourceRewriter shaderSourceRewriter = new(structDeclarationSymbol, semanticModel, discoveredTypes, staticMethods, constantDefinitions);
// Rewrite the method syntax tree
var processedMethod = shaderSourceRewriter.Visit(methodDeclaration)!.WithoutTrivia();
MethodDeclarationSyntax? processedMethod = shaderSourceRewriter.Visit(methodDeclaration)!.WithoutTrivia();
// If the method is the shader entry point, do additional processing
if (methodDeclarationSymbol.Name == nameof(IComputeShader.Execute) &&
methodDeclarationSymbol.ReturnsVoid &&
methodDeclarationSymbol.TypeParameters.Length == 0 &&
methodDeclarationSymbol.Parameters.Length == 1 &&
methodDeclarationSymbol.Parameters[0].Type.ToDisplayString() == typeof(ThreadIds).FullName)
methodDeclarationSymbol.Parameters.Length == 0)
{
var parameterName = methodDeclarationSymbol.Parameters[0].Name;
processedMethod = new ExecuteMethodRewriter(parameterName).Visit(processedMethod)!;
processedMethod = new ExecuteMethodRewriter(shaderSourceRewriter).Visit(processedMethod)!;
entryPoint = processedMethod.NormalizeWhitespace().ToFullString();
}
+43
ファイルの表示
@@ -190,6 +190,49 @@ namespace ComputeSharp.SourceGenerators.Mappings
knownMembers.Add($"{item.Type.FullName}{Type.Delimiter}{item.Property.Name}", $"{item.Property.Name.ToLower()}");
}
// Store GroupIds.Index for a quicker comparison afterwards
PropertyInfo groupindexProperty = typeof(GroupIds).GetProperty(nameof(GroupIds.Index), BindingFlags.Static | BindingFlags.Public);
// Programmatically load mappings for the dispatch types
foreach (var item in
from type in HlslKnownTypes.HlslDispatchTypes
from property in type.GetProperties(BindingFlags.Static | BindingFlags.Public)
select (Type: type, Property: property))
{
if (item.Property == groupindexProperty)
{
// The thread group index is a standalone parameter, so if this property is used, we
// just map the access directly to that implicit and hidden parameter name instead.
knownMembers.Add($"{item.Type.FullName}{Type.Delimiter}{item.Property.Name}", $"__{nameof(GroupIds)}__get_Index");
}
else
{
knownMembers.Add($"{item.Type.FullName}{Type.Delimiter}{item.Property.Name}", $"{item.Type.Name}.{item.Property.Name.ToLower()}");
}
}
// Programmatically load mappings for the group size
foreach (var property in typeof(GroupSize).GetProperties(BindingFlags.Static | BindingFlags.Public))
{
string key = $"{typeof(GroupSize).FullName}{Type.Delimiter}{property.Name}";
switch (property.Name)
{
case nameof(GroupSize.Count):
knownMembers.Add(key, "__GroupSize__get_X * __GroupSize__get_Y * __GroupSize__get_Z");
break;
case string name when name.Length == 1:
knownMembers.Add(key, $"__GroupSize__get_{name}");
break;
case string name when name.Length == 1:
knownMembers.Add(key, $"__GroupSize__get_{name[0]} * __GroupSize__get_{name[1]}");
break;
case string name when name.Length == 1:
knownMembers.Add(key, $"__GroupSize__get_{name[0]} * __GroupSize__get_{name[1]} * __GroupSize__get_{name[2]}");
break;
}
}
return knownMembers;
}
+30 -6
ファイルの表示
@@ -41,8 +41,7 @@ namespace ComputeSharp.SourceGenerators.Mappings
[typeof(double).FullName] = "double",
[typeof(Double2).FullName] = "double2",
[typeof(Double3).FullName] = "double3",
[typeof(Double4).FullName] = "double4",
[typeof(ThreadIds).FullName] = "int3"
[typeof(Double4).FullName] = "double4"
};
/// <summary>
@@ -50,7 +49,6 @@ namespace ComputeSharp.SourceGenerators.Mappings
/// </summary>
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),
@@ -58,6 +56,16 @@ namespace ComputeSharp.SourceGenerators.Mappings
typeof(Double2), typeof(Double3), typeof(Double4)
};
/// <summary>
/// Gets the known HLSL dispatch types.
/// </summary>
public static IReadOnlyCollection<Type> HlslDispatchTypes { get; } = new[]
{
typeof(ThreadIds),
typeof(GroupIds),
typeof(WarpIds)
};
/// <summary>
/// Checks whether or not a given type name matches a typed resource type.
/// </summary>
@@ -94,9 +102,7 @@ namespace ComputeSharp.SourceGenerators.Mappings
/// <returns>Whether or not <paramref name="typeName"/> represents a typed resource type.</returns>
public static bool IsScalarOrVectorType(string typeName)
{
return
KnownTypes.ContainsKey(typeName) &&
typeName != typeof(ThreadIds).FullName;
return KnownTypes.ContainsKey(typeName);
}
/// <summary>
@@ -149,6 +155,24 @@ namespace ComputeSharp.SourceGenerators.Mappings
return KnownTypes[typeName];
}
/// <summary>
/// Gets the mapped HLSL-compatible type name for the input element type symbol.
/// </summary>
/// <param name="typeSymbol">The input type to map.</param>
/// <returns>The HLSL-compatible type name that can be used in an HLSL shader.</returns>
[Pure]
public static string GetMappedElementName(IArrayTypeSymbol typeSymbol)
{
string elementTypeName = ((INamedTypeSymbol)typeSymbol.ElementType).GetFullMetadataName();
if (KnownTypes.TryGetValue(elementTypeName, out string? mapped))
{
return mapped;
}
return elementTypeName.Replace(".", "__");
}
/// <summary>
/// Gets the mapped HLSL-compatible type name for the input type name.
/// </summary>
+31 -14
ファイルの表示
@@ -11,17 +11,17 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
internal sealed class ExecuteMethodRewriter : CSharpSyntaxRewriter
{
/// <summary>
/// The identifier name for the input <see langword="uint3"/> parameter.
/// The <see cref="ShaderSourceRewriter"/> instance used to process the input tree.
/// </summary>
private readonly string threadIdsIdentifier;
private readonly ShaderSourceRewriter shaderSourceRewriter;
/// <summary>
/// Creates a new <see cref="ExecuteMethodRewriter"/> instance with the specified parameters.
/// </summary>
/// <param name="threadIdsIdentifier">The identifier name for the input <see langword="uint3"/> parameter.</param>
public ExecuteMethodRewriter(string threadIdsIdentifier)
/// <param name="shaderSourceRewriter">The <see cref="ShaderSourceRewriter"/> instance used to process the input tree.</param>
public ExecuteMethodRewriter(ShaderSourceRewriter shaderSourceRewriter)
{
this.threadIdsIdentifier = threadIdsIdentifier;
this.shaderSourceRewriter = shaderSourceRewriter;
}
/// <inheritdoc cref="CSharpSyntaxRewriter.Visit(SyntaxNode?)"/>
@@ -32,11 +32,28 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
}
/// <inheritdoc/>
public override SyntaxNode VisitParameter(ParameterSyntax node)
public override SyntaxNode? VisitParameterList(ParameterListSyntax node)
{
var updatedNode = (ParameterSyntax)base.VisitParameter(node)!;
var updatedNode = (ParameterListSyntax)base.VisitParameterList(node)!;
return updatedNode.WithIdentifier(Identifier($"{updatedNode.Identifier.Text} : SV_DispatchThreadId"));
updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(ThreadIds)} : SV_DispatchThreadID")));
if (this.shaderSourceRewriter.IsGroupIdsUsed)
{
updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(GroupIds)} : SV_GroupThreadID")));
}
if (this.shaderSourceRewriter.IsGroupIdsIndexUsed)
{
updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint __{nameof(GroupIds)}__get_Index : SV_GroupIndex")));
}
if (this.shaderSourceRewriter.IsWarpIdsUsed)
{
updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(WarpIds)} : SV_GroupID")));
}
return updatedNode;
}
/// <inheritdoc/>
@@ -48,9 +65,9 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
// check to ensure that invocation outside of the requested range are discarded.
// The following snippet creates this prologue before the user provided body:
//
// if (ids.X < __x &&
// ids.Y < __y &&
// ids.Z < __z)
// if (ThreadIds.x < __x &&
// ThreadIds.y < __y &&
// ThreadIds.z < __z)
// {
// <body>
// }
@@ -60,19 +77,19 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("x")),
IdentifierName("__x")),
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("y")),
IdentifierName("__y"))),
BinaryExpression(SyntaxKind.LessThanExpression,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(this.threadIdsIdentifier),
IdentifierName(nameof(ThreadIds)),
IdentifierName("z")),
IdentifierName("__z")));
+28 -3
ファイルの表示
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using ComputeSharp.SourceGenerators.Extensions;
using ComputeSharp.SourceGenerators.Mappings;
@@ -107,6 +106,21 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
/// </summary>
public IReadOnlyDictionary<string, LocalFunctionStatementSyntax> LocalFunctions => this.localFunctions;
/// <summary>
/// Gets whether or not the shader uses <see cref="GroupIds"/> at least once (except <see cref="GroupIds.Index"/>).
/// </summary>
public bool IsGroupIdsUsed { get; private set; }
/// <summary>
/// Gets whether or not the shader uses <see cref="GroupIds.Index/> at least once.
/// </summary>
public bool IsGroupIdsIndexUsed { get; private set; }
/// <summary>
/// Gets whether or not the shader uses <see cref="WarpIds"/> at least once.
/// </summary>
public bool IsWarpIdsUsed { get; set; }
/// <inheritdoc cref="CSharpSyntaxRewriter.Visit(SyntaxNode?)"/>
public MethodDeclarationSyntax? Visit(MethodDeclarationSyntax? node)
{
@@ -308,11 +322,22 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
// to see if the member should be rewritten for HLSL compliance, and rewrite if needed.
if (HlslKnownMembers.TryGetMappedName(operation.Member.ToDisplayString(), out string? mapping))
{
// Mark which dispatch properties have been used, to optimize the declaration afterwards
if (operation.Member.IsStatic)
{
string typeName = operation.Member.ContainingType.GetFullMetadataName();
if (mapping == $"__{nameof(GroupIds)}__get_Index") IsGroupIdsIndexUsed = true;
else if (typeName == typeof(GroupIds).FullName) IsGroupIdsUsed = true;
else if (typeName == typeof(WarpIds).FullName) IsWarpIdsUsed = true;
}
// Static and instance members are handled differently, with static members being
// converted into a literal expression, and instance getting an updated identifier.
// For instance, consider these two cases:
// For instance, consider these three cases:
// - Vector3.One (static) => float3(1.0f, 1.0f, 1.0f)
// - ThredIds.X (instance) => [arg].x
// - ThreadIds.X (custom) => ThreadIds.x
// - uint3.X (instance) => [arg].x
return operation.Member.IsStatic switch
{
true => ParseExpression(mapping!),
+2
ファイルの表示
@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
+1 -1
ファイルの表示
@@ -68,7 +68,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="bufferOffset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
public static void GetData<T>(this Buffer<T> buffer, T[] destination, int destinationOffset, int bufferOffset, int count)
+3 -3
ファイルの表示
@@ -93,7 +93,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int offset)
where T : unmanaged
{
@@ -107,7 +107,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
public static void GetData<T>(this Texture2D<T> texture, T[] destination, int offset, Range x, Range y)
@@ -123,7 +123,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
+5 -5
ファイルの表示
@@ -41,7 +41,7 @@ namespace ComputeSharp
/// <param name="destination">The input array to write data to.</param>
/// <remarks>
/// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be [<see cref="Depth"/>, <see cref="Height"/>, <see cref="Width"/>].
/// layout of the input array has to be of shape [depth, height, width].
/// </remarks>
public static void GetData<T>(this Texture3D<T> texture, T[,,] destination)
where T : unmanaged
@@ -59,7 +59,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
public static void GetData<T>(this Texture3D<T> texture, T[] destination, int offset)
where T : unmanaged
{
@@ -73,7 +73,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="x">The horizontal range of items to copy.</param>
/// <param name="y">The vertical range of items to copy.</param>
/// <param name="z">The depthwise range of items to copy.</param>
@@ -90,7 +90,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
@@ -162,7 +162,7 @@ namespace ComputeSharp
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <remarks>
/// The source 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be [<see cref="Depth"/>, <see cref="Height"/>, <see cref="Width"/>].
/// layout of the input array has to be of shape [depth, height, width].
/// </remarks>
public static void SetData<T>(this Texture3D<T> texture, T[,,] source)
where T : unmanaged
+8 -8
ファイルの表示
@@ -178,7 +178,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <returns>A <see cref="ReadOnlyTexture2D{T}"/> instance with the contents of the input array.</returns>
@@ -269,7 +269,7 @@ namespace ComputeSharp
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <returns>A <see cref="ReadOnlyTexture2D{T,TPixel}"/> instance with the contents of the input array.</returns>
@@ -362,7 +362,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
@@ -461,7 +461,7 @@ namespace ComputeSharp
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
@@ -622,7 +622,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <returns>A <see cref="ReadWriteTexture2D{T}"/> instance with the contents of the input array.</returns>
@@ -713,7 +713,7 @@ namespace ComputeSharp
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <returns>A <see cref="ReadWriteTexture2D{T,TPixel}"/> instance with the contents of the input array.</returns>
@@ -806,7 +806,7 @@ namespace ComputeSharp
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
@@ -905,7 +905,7 @@ namespace ComputeSharp
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
/// <param name="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="array"/> to read data from.</param>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="depth">The depth of the texture.</param>
+2 -2
ファイルの表示
@@ -13,7 +13,7 @@ namespace ComputeSharp.Tests.Internals
public float A;
public ReadWriteBuffer<float> B;
public void Execute(ThreadIds ids)
public void Execute()
{
B[0] = A;
}
@@ -46,7 +46,7 @@ namespace ComputeSharp.Tests.Internals
public ReadWriteBuffer<float> B;
public Func<float, float> F;
public void Execute(ThreadIds ids)
public void Execute()
{
B[0] = F(A);
}
+6 -6
ファイルの表示
@@ -223,9 +223,9 @@ namespace ComputeSharp.Tests
public readonly ConstantBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.X] = source[ids.X];
destination[ThreadIds.X] = source[ThreadIds.X];
}
}
@@ -250,9 +250,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.X] = source[ids.X];
destination[ThreadIds.X] = source[ThreadIds.X];
}
}
@@ -277,9 +277,9 @@ namespace ComputeSharp.Tests
public readonly ReadWriteBuffer<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.X] = source[ids.X];
destination[ThreadIds.X] = source[ThreadIds.X];
}
}
}
+112
ファイルの表示
@@ -0,0 +1,112 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests
{
[TestClass]
[TestCategory("Dispatch")]
public partial class DispatchTests
{
[TestMethod]
public void Verify_ThreadIds()
{
using ReadWriteTexture3D<Int4> buffer = Gpu.Default.AllocateReadWriteTexture3D<Int4>(50, 50, 50);
Gpu.Default.For(buffer.Width, buffer.Height, buffer.Depth, new ThreadIdsShader(buffer));
Int4[,,] data = buffer.GetData();
for (int z = 0; z < 50; z++)
{
for (int x = 0; x < 50; x++)
{
for (int y = 0; y < 50; y++)
{
Int4 value = data[z, y, x];
Assert.AreEqual(x, value.X);
Assert.AreEqual(y, value.Y);
Assert.AreEqual(z, value.Z);
}
}
}
}
[AutoConstructor]
internal readonly partial struct ThreadIdsShader : IComputeShader
{
public readonly ReadWriteTexture3D<Int4> buffer;
public void Execute()
{
buffer[ThreadIds.XYZ].XYZ = ThreadIds.XYZ;
}
}
[TestMethod]
public void Verify_GroupIds()
{
using ReadWriteTexture3D<Int4> buffer = Gpu.Default.AllocateReadWriteTexture3D<Int4>(50, 50, 50);
Gpu.Default.For(buffer.Width, buffer.Height, buffer.Depth, 4, 4, 4, new GroupIdsShader(buffer));
Int4[,,] data = buffer.GetData();
for (int z = 0; z < 50; z++)
{
for (int x = 0; x < 50; x++)
{
for (int y = 0; y < 50; y++)
{
Int4 value = data[z, y, x];
Assert.AreEqual(x % 4, value.X);
Assert.AreEqual(y % 4, value.Y);
Assert.AreEqual(z % 4, value.Z);
Assert.AreEqual(value.Z * 4 * 4 + value.Y * 4 + value.X, value.W);
}
}
}
}
[AutoConstructor]
internal readonly partial struct GroupIdsShader : IComputeShader
{
public readonly ReadWriteTexture3D<Int4> buffer;
public void Execute()
{
buffer[ThreadIds.XYZ].XYZ = GroupIds.XYZ;
buffer[ThreadIds.XYZ].W = GroupIds.Index;
}
}
[TestMethod]
public void Verify_GroupSize()
{
using ReadWriteBuffer<int> buffer = Gpu.Default.AllocateReadWriteBuffer<int>(32);
Gpu.Default.For(1, 1, 1, 4, 15, 7, new GroupSizeShader(buffer));
int[] data = buffer.GetData();
Assert.AreEqual(4, data[0]);
Assert.AreEqual(15, data[1]);
Assert.AreEqual(7, data[2]);
Assert.AreEqual(4 * 15 * 7, data[3]);
}
[AutoConstructor]
internal readonly partial struct GroupSizeShader : IComputeShader
{
public readonly ReadWriteBuffer<int> buffer;
public void Execute()
{
buffer[0] = GroupSize.X;
buffer[1] = GroupSize.Y;
buffer[2] = GroupSize.Z;
buffer[3] = GroupSize.Count;
}
}
}
}
+2 -2
ファイルの表示
@@ -86,9 +86,9 @@ namespace ComputeSharp.Tests
{
public readonly ReadWriteBuffer<int> buffer;
public void Execute(ThreadIds ids)
public void Execute()
{
buffer[ids.X] = ids.X;
buffer[ThreadIds.X] = ThreadIds.X;
}
}
}
+24 -24
ファイルの表示
@@ -113,9 +113,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Bgra32, Vector4> source;
public readonly ReadWriteTexture2D<Bgra32, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -125,9 +125,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Bgra32, Float4> source;
public readonly ReadWriteTexture2D<Bgra32, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -137,9 +137,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<R16, float> source;
public readonly ReadWriteTexture2D<R16, float> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -149,9 +149,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<R8, float> source;
public readonly ReadWriteTexture2D<R8, float> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -161,9 +161,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rg16, Vector2> source;
public readonly ReadWriteTexture2D<Rg16, Vector2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -173,9 +173,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rg16, Float2> source;
public readonly ReadWriteTexture2D<Rg16, Float2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -185,9 +185,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rg32, Vector2> source;
public readonly ReadWriteTexture2D<Rg32, Vector2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -197,9 +197,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rg32, Float2> source;
public readonly ReadWriteTexture2D<Rg32, Float2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -209,9 +209,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rgba32, Vector4> source;
public readonly ReadWriteTexture2D<Rgba32, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -221,9 +221,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rgba32, Float4> source;
public readonly ReadWriteTexture2D<Rgba32, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -233,9 +233,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rgba64, Vector4> source;
public readonly ReadWriteTexture2D<Rgba64, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
@@ -245,9 +245,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<Rgba64, Float4> source;
public readonly ReadWriteTexture2D<Rgba64, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
}
+2 -2
ファイルの表示
@@ -69,9 +69,9 @@ foreach (var (t, tPixel) in EnumerateTypes())
public readonly ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source;
public readonly ReadWriteTexture2D<<#=t#>, <#=tPixel#>> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = (source[ids.XY] + destination[ids.XY]) / 2;
destination[ThreadIds.XY] = (source[ThreadIds.XY] + destination[ThreadIds.XY]) / 2;
}
}
<#
+4 -4
ファイルの表示
@@ -159,9 +159,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture2D<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.Y * 32 + ids.X] = source[ids.XY];
destination[ThreadIds.Y * 32 + ThreadIds.X] = source[ThreadIds.XY];
}
}
@@ -188,9 +188,9 @@ namespace ComputeSharp.Tests
public readonly ReadWriteTexture2D<int> source;
public readonly ReadWriteTexture2D<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XY] = source[ids.XY];
destination[ThreadIds.XY] = source[ThreadIds.XY];
}
}
}
+24 -24
ファイルの表示
@@ -113,9 +113,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Bgra32, Vector4> source;
public readonly ReadWriteTexture3D<Bgra32, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -125,9 +125,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Bgra32, Float4> source;
public readonly ReadWriteTexture3D<Bgra32, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -137,9 +137,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<R16, float> source;
public readonly ReadWriteTexture3D<R16, float> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -149,9 +149,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<R8, float> source;
public readonly ReadWriteTexture3D<R8, float> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -161,9 +161,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rg16, Vector2> source;
public readonly ReadWriteTexture3D<Rg16, Vector2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -173,9 +173,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rg16, Float2> source;
public readonly ReadWriteTexture3D<Rg16, Float2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -185,9 +185,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rg32, Vector2> source;
public readonly ReadWriteTexture3D<Rg32, Vector2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -197,9 +197,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rg32, Float2> source;
public readonly ReadWriteTexture3D<Rg32, Float2> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -209,9 +209,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rgba32, Vector4> source;
public readonly ReadWriteTexture3D<Rgba32, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -221,9 +221,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rgba32, Float4> source;
public readonly ReadWriteTexture3D<Rgba32, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -233,9 +233,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rgba64, Vector4> source;
public readonly ReadWriteTexture3D<Rgba64, Vector4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
@@ -245,9 +245,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<Rgba64, Float4> source;
public readonly ReadWriteTexture3D<Rgba64, Float4> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
}
+2 -2
ファイルの表示
@@ -69,9 +69,9 @@ foreach (var (t, tPixel) in EnumerateTypes())
public readonly ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source;
public readonly ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = (source[ids.XYZ] + destination[ids.XYZ]) / 2;
destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2;
}
}
<#
+4 -4
ファイルの表示
@@ -193,9 +193,9 @@ namespace ComputeSharp.Tests
public readonly ReadOnlyTexture3D<int> source;
public readonly ReadWriteBuffer<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.Z * 32 * 32 + ids.Y * 32 + ids.X] = source[ids.XYZ];
destination[ThreadIds.Z * 32 * 32 + ThreadIds.Y * 32 + ThreadIds.X] = source[ThreadIds.XYZ];
}
}
@@ -222,9 +222,9 @@ namespace ComputeSharp.Tests
public readonly ReadWriteTexture3D<int> source;
public readonly ReadWriteTexture3D<int> destination;
public void Execute(ThreadIds ids)
public void Execute()
{
destination[ids.XYZ] = source[ids.XYZ];
destination[ThreadIds.XYZ] = source[ThreadIds.XYZ];
}
}
}