Fork me on GitHub


Safe Rust wrapper around the Vulkan API


Now that we have all the needed ingredients, we can create the command buffer that will execute our compute pipeline. This is called a dispatch operation.

Creating a command buffer is similar to the example operation in a previous section.

let command_buffer = AutoCommandBufferBuilder::new(device.clone(),
    .dispatch([1024, 1, 1], compute_pipeline.clone(), set.clone(), ()).unwrap()

As explained in the compute pipeline section, we want to spawn 1024 work groups. This value is indicated when we add the command to the command buffer.

Note: The last parameter contains the push constants, which we haven't covered yet. Push constants are a way to pass a small amount of data to a shader, as an alternative to putting this data in a buffer in a descriptor set.

Just like we already covered, we submit the command buffer:

let finished = command_buffer.execute(queue.clone()).unwrap();

This just schedules the operation for execution. We have to wait for it to be complete:


Once complete we can check that the pipeline has been correctly executed:

let content =;
for (n, val) in content.iter().enumerate() {
    assert_eq!(*val, n as u32 * 12);

println!("Everything succeeded!");