Remove shared sample project, move files to project

このコミットが含まれているのは:
Sergio Pedri committed 2022-06-26 21:52:44 +02:00
1 親 c4f04fe5cd
コミット 29ade3845a
5ファイル変更
-8

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

+36
ファイルの表示
@@ -0,0 +1,36 @@
using System;
using System.Linq;
using ComputeSharp;
using ComputeSharp.Sample;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
using ReadWriteBuffer<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
// Run the shader
GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
// Print the initial matrix
Formatting.PrintMatrix(array, 10, 10, "BEFORE");
// Get the data back
gpuBuffer.CopyTo(array);
// Print the updated matrix
Formatting.PrintMatrix(array, 10, 10, "AFTER");
/// <summary>
/// The sample kernel that multiples all items by two.
/// </summary>
[AutoConstructor]
internal readonly partial struct MultiplyByTwo : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= 2;
}
}