| using ILGPU;
|
| using ILGPU.Runtime;
|
| using System;
|
|
|
| namespace FastPrint.Slicing
|
| {
|
| public class SliceAccelerator : IDisposable
|
| {
|
| private Context context;
|
| private Accelerator accelerator;
|
|
|
| public SliceAccelerator()
|
| {
|
| context = Context.CreateDefault();
|
| accelerator = context.GetPreferredDevice(preferCPU: false).CreateAccelerator(context);
|
| }
|
|
|
|
|
| public void Slice(float[] vertices, float layerHeight, Action<float[]> onSliced)
|
| {
|
| using var buffer = accelerator.Allocate1D(vertices);
|
| accelerator.Synchronize();
|
|
|
| onSliced(vertices);
|
| }
|
|
|
| public void Dispose()
|
| {
|
| accelerator.Dispose();
|
| context.Dispose();
|
| }
|
| }
|
| } |