2024-06-05 19:34:24 +00:00
|
|
|
|
using RefreshCS;
|
2021-01-20 03:33:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace MoonWorks.Graphics
|
|
|
|
|
{
|
2023-09-19 20:19:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Compute pipelines perform arbitrary parallel processing on input data.
|
|
|
|
|
/// </summary>
|
2024-06-05 19:34:24 +00:00
|
|
|
|
public class ComputePipeline : RefreshResource
|
2022-02-23 05:14:32 +00:00
|
|
|
|
{
|
2024-06-05 19:34:24 +00:00
|
|
|
|
protected override Action<IntPtr, IntPtr> ReleaseFunction => Refresh.Refresh_ReleaseComputePipeline;
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2024-06-05 00:24:25 +00:00
|
|
|
|
public ComputePipelineResourceInfo ResourceInfo { get; }
|
2021-01-27 22:02:46 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public unsafe ComputePipeline(
|
|
|
|
|
GraphicsDevice device,
|
2024-06-05 00:24:25 +00:00
|
|
|
|
Shader computeShader,
|
|
|
|
|
ComputePipelineResourceInfo resourceInfo
|
2022-02-23 05:14:32 +00:00
|
|
|
|
) : base(device)
|
|
|
|
|
{
|
2024-06-05 19:37:02 +00:00
|
|
|
|
var refreshComputePipelineCreateInfo = new Refresh.ComputePipelineCreateInfo
|
2022-02-23 05:14:32 +00:00
|
|
|
|
{
|
2024-06-05 00:24:25 +00:00
|
|
|
|
ComputeShader = computeShader.Handle,
|
2024-06-05 19:34:24 +00:00
|
|
|
|
PipelineResourceInfo = resourceInfo.ToRefresh()
|
2022-02-23 05:14:32 +00:00
|
|
|
|
};
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2024-06-05 19:34:24 +00:00
|
|
|
|
Handle = Refresh.Refresh_CreateComputePipeline(
|
2022-02-23 05:14:32 +00:00
|
|
|
|
device.Handle,
|
2024-06-05 19:37:02 +00:00
|
|
|
|
refreshComputePipelineCreateInfo
|
2022-02-23 05:14:32 +00:00
|
|
|
|
);
|
2024-06-05 00:24:25 +00:00
|
|
|
|
|
2022-11-08 19:29:05 +00:00
|
|
|
|
if (Handle == IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Could not create compute pipeline!");
|
|
|
|
|
}
|
2021-01-27 22:02:46 +00:00
|
|
|
|
|
2024-06-05 00:24:25 +00:00
|
|
|
|
ResourceInfo = resourceInfo;
|
2022-02-23 05:14:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
}
|