web api interface
GPUComputePipeline
Secure contextAvailable in workers
The GPUComputePipeline interface of the WebGPU API represents a pipeline that controls the compute shader stage and can be used in a GPUComputePassEncoder.
A GPUComputePipeline object instance can be created using the createComputePipeline() or createComputePipelineAsync() methods.
Instance properties
label- : A string providing a label that can be used to identify the object, for example in
GPUErrormessages or console warnings.
- : A string providing a label that can be used to identify the object, for example in
Instance methods
getBindGroupLayout()- : Returns the pipeline’s
GPUBindGroupLayoutobject with the given index (i.e., included in the originatingcreateComputePipeline()orcreateComputePipelineAsync()call’s pipeline layout).
- : Returns the pipeline’s
Examples
[!NOTE] The WebGPU samples feature many more examples.
Basic example
Our basic compute demo shows a process of:
- Creating a bind group layout with
createBindGroupLayout(). - Feeding the
bindGroupLayoutintocreatePipelineLayout()to create aGPUPipelineLayout. - Using that value immediately in a
createComputePipeline()call to create aGPUComputePipeline.
// …
const bindGroupLayout = device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUShaderStage.COMPUTE,
buffer: {
type: "storage",
},
},
],
});
const computePipeline = device.createComputePipeline({
layout: device.createPipelineLayout({
bindGroupLayouts: [bindGroupLayout],
}),
compute: {
module: shaderModule,
entryPoint: "main",
},
});
// …
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- The WebGPU API