compute.createPipeline#pipeline¶
Summary¶
compute.createPipeline#pipeline exposes the native WebGPU compute pipeline. Use it to bind the same compiled program in a manually recorded compute pass, along with groups from the wrapper.
Syntax¶
readonly ComputePipeline.pipeline: GPUComputePipeline
readonly ComputePipeline.device: GPUDevice
readonly ComputePipeline.shaderCode: string
readonly ComputePipeline.entryPoint: string
readonly ComputePipeline.constants: Record<string, number> | undefined
readonly ComputePipeline.bindGroupLayouts: GPUBindGroupLayout[]
pass.setPipeline(kernel.pipeline);
Returns¶
GPUComputePipeline - The compiled pipeline on device. The wrapper also exposes the shader source, entry point and constants used to create it. The entry point defaults to "main".
Example¶
const kernel = wgpu.compute.createPipeline({
code: "@compute @workgroup_size(1) fn main() {}"
});
const encoder = wgpu.gpu.device.createCommandEncoder();
const pass = encoder.beginComputePass();
pass.setPipeline(kernel.pipeline);
pass.dispatchWorkgroups(1);
pass.end();
wgpu.gpu.queue.submit([encoder.finish()]);
Notes¶
bindGroupLayouts stores only explicit layouts. Use getBindGroupLayout to look up a layout for either explicit or inferred groups.