Description
The DispatchCompute
method is used to execute a compute shader on the GPU. This method allows you to specify the number of work groups to be dispatched in the x, y, and z dimensions. It is a part of the CommandList
class within the Sandbox.Rendering
namespace.
Usage
To use the DispatchCompute
method, you need to have a valid ComputeShader
object and specify the number of work groups in each dimension. This method is typically used in rendering pipelines where compute shaders are employed for tasks such as physics simulations, image processing, or other parallel computations.
Example
// Create a new CommandList
CommandList commandList = new CommandList();
// Assume computeShader is a valid ComputeShader object
ComputeShader computeShader = new ComputeShader();
// Dispatch the compute shader with 10 work groups in x, 5 in y, and 2 in z dimensions
commandList.DispatchCompute(computeShader, 10, 5, 2);