using RefreshCS;
using System;
namespace MoonWorks.Graphics
{
///
/// Compute pipelines perform arbitrary parallel processing on input data.
///
public class ComputePipeline : RefreshResource
{
protected override Action ReleaseFunction => Refresh.Refresh_ReleaseComputePipeline;
public ComputePipelineResourceInfo ResourceInfo { get; }
public unsafe ComputePipeline(
GraphicsDevice device,
Shader computeShader,
ComputePipelineResourceInfo resourceInfo
) : base(device)
{
var refreshComputePipelineCreateInfo = new Refresh.ComputePipelineCreateInfo
{
ComputeShader = computeShader.Handle,
PipelineResourceInfo = resourceInfo.ToRefresh()
};
Handle = Refresh.Refresh_CreateComputePipeline(
device.Handle,
refreshComputePipelineCreateInfo
);
if (Handle == IntPtr.Zero)
{
throw new Exception("Could not create compute pipeline!");
}
ResourceInfo = resourceInfo;
}
}
}