MoonWorks/src/Graphics/Resources/ComputePipeline.cs

41 lines
984 B
C#
Raw Permalink Normal View History

2024-06-05 19:34:24 +00:00
using RefreshCS;
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;
2024-06-05 00:24:25 +00:00
public ComputePipelineResourceInfo ResourceInfo { get; }
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
};
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
if (Handle == IntPtr.Zero)
{
throw new Exception("Could not create compute pipeline!");
}
2024-06-05 00:24:25 +00:00
ResourceInfo = resourceInfo;
2022-02-23 05:14:32 +00:00
}
}
}