MoonWorks-docs/content/Graphics/Resources/ComputePipeline.md

1.4 KiB

title date weight
Compute Pipeline 2021-01-28T13:55:13-08:00 9

There is another kind of pipeline we have access to other than graphics pipelines, and that is compute pipelines. Whereas graphics pipelines are specifically constructed for rendering, compute pipelines can do parallel processing on any kind of input data and output any kind of data we want. Some common use cases for compute pipelines are particle systems and sprite batching.

Describing exactly how to use compute pipelines is (my favorite phrase!) beyond the scope of this tutorial, so you should seek out other resources to learn how to use them. Many games will never need a compute pipeline and at the point where you could benefit from one you will probably know.

To construct a compute pipeline, we need a shader stage state containing a compute shader module, a buffer binding count, and an image binding count.

var myComputeShader = new ShaderModule(
    GraphicsDevice,
    "ParticleCompute.spv"
);

var myComputeShaderInfo = new ComputeShaderInfo
{
    ShaderModule = myComputeShader,
    EntryPointName = "main",
    UniformBufferSize = 0,
	BufferBindingCount = 1,
	ImageBindingCount = 0,
};

var myComputePipeline = new ComputePipeline(
    GraphicsDevice,
	myComputeShaderInfo
);

This example creates a compute pipeline with no uniform input, one buffer binding, and no image bindings.