Added new generic extensions

このコミットが含まれているのは:
Sergio Pedri committed 2020-04-12 20:33:25 +02:00
1 親 9324a3a42b
コミット 80f35ddcd2
1ファイル変更
+64
+64
ファイルの表示
@@ -52,5 +52,69 @@ namespace ComputeSharp
int x, int y, int z,
int threadsX, int threadsY, int threadsZ,
Action<ThreadIds> action) => ShaderRunner.Run(device, x, y, z, threadsX, threadsY, threadsZ, action);
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters
/// </summary>
/// <typeparam name="T">The type of compute shader to run</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader</param>
/// <param name="x">The number of iterations to run on the X axis</param>
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run</param>
public static void For<T>(this GraphicsDevice device, int x, in T shader)
where T : struct, IComputeShader
{
ShaderRunner<T>.Run(device, x, 1, 1, shader);
}
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters
/// </summary>
/// <typeparam name="T">The type of compute shader to run</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader</param>
/// <param name="x">The number of iterations to run on the X axis</param>
/// <param name="y">The number of iterations to run on the Y axis</param>
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run</param>
public static void For<T>(this GraphicsDevice device, int x, int y, in T shader)
where T : struct, IComputeShader
{
ShaderRunner<T>.Run(device, x, y, 1, shader);
}
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters
/// </summary>
/// <typeparam name="T">The type of compute shader to run</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader</param>
/// <param name="x">The number of iterations to run on the X axis</param>
/// <param name="y">The number of iterations to run on the Y axis</param>
/// <param name="z">The number of iterations to run on the Z axis</param>
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run</param>
public static void For<T>(this GraphicsDevice device, int x, int y, int z, in T shader)
where T : struct, IComputeShader
{
ShaderRunner<T>.Run(device, x, y, z, shader);
}
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters
/// </summary>
/// <typeparam name="T">The type of compute shader to run</typeparam>
/// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader</param>
/// <param name="x">The number of iterations to run on the X axis</param>
/// <param name="y">The number of iterations to run on the Y axis</param>
/// <param name="z">The number of iterations to run on the Z axis</param>
/// <param name="threadsX">The number of threads in each thread group for the X axis</param>
/// <param name="threadsY">The number of threads in each thread group for the Y axis</param>
/// <param name="threadsZ">The number of threads in each thread group for the Z axis</param>
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run</param>
public static void For<T>(
this GraphicsDevice device,
int x, int y, int z,
int threadsX, int threadsY, int threadsZ,
in T shader)
where T : struct, IComputeShader
{
ShaderRunner<T>.Run(device, x, y, z, threadsX, threadsY, threadsZ, shader);
}
}
}