The setPipeline()
method of the GPUComputePassEncoder
interface sets the GPUComputePipeline
to use for this compute pass.
In our basic compute demo, several commands are recorded via a GPUCommandEncoder
. Most of these commands originate from the GPUComputePassEncoder
created via beginComputePass()
. The setPipeline()
call is used as appropriate to set the pipeline to use for this pass.
const BUFFER_SIZE = 1000;
const commandEncoder = device.createCommandEncoder();
const passEncoder = commandEncoder.beginComputePass();
passEncoder.setPipeline(computePipeline);
passEncoder.setBindGroup(0, bindGroup);
passEncoder.dispatchWorkgroups(Math.ceil(BUFFER_SIZE / 64));
passEncoder.end();
commandEncoder.copyBufferToBuffer(
output,
0,
stagingBuffer,
0,
BUFFER_SIZE,
);
device.queue.submit([commandEncoder.finish()]);