This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The createComputePipeline() method of the GPUDevice interface creates a GPUComputePipeline that can control the compute shader stage and be used in a GPUComputePassEncoder.
createComputePipeline(descriptor)
descriptorAn object containing the following properties:
computeAn object describing the compute shader entry point of the pipeline. This object can contain the following properties:
constants OptionalA sequence of record types, with the structure (id, value), representing override values for WGSL constants that can be overridden in the pipeline. These behave like ordered maps. In each case, the id is a key used to identify or select the record, and the constant is an enumerated value representing a WGSL.
Depending on which constant you want to override, the id may take the form of the numeric ID of the constant, if one is specified, or otherwise the constant's identifier name.
A code snippet providing override values for several overridable constants might look like this:
({
// …
constants: {
0: false,
1200: 3.0,
1300: 2.0,
width: 20,
depth: -1,
height: 15,
},
});
entryPoint OptionalThe name of the function in the module that this stage will use to perform its work. The corresponding shader function must have the @compute attribute to be identified as this entry point. See Entry Point Declaration for more information.
You can omit the entryPoint property if your shader code contains a single function with the @compute attribute set — the browser will use this as the default entry point. If entryPoint is omitted and the browser cannot determine a default entry point, a GPUValidationError is generated and the resulting GPUComputePipeline will be invalid.
moduleA GPUShaderModule object containing the WGSL code that this programmable stage will execute.
label OptionalA string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.
layoutDefines the layout (structure, purpose, and type) of all the GPU resources (buffers, textures, etc.) used during the execution of the pipeline. Possible values are:
GPUPipelineLayout object, created using GPUDevice.createPipelineLayout(), which allows the GPU to figure out how to run the pipeline most efficiently ahead of time."auto", which causes the pipeline to generate an implicit bind group layout based on any bindings defined in the shader code. If "auto" is used, the generated bind group layouts may only be used with the current pipeline.A GPUComputePipeline object instance.
The following criteria must be met when calling createComputePipeline(), otherwise a GPUValidationError is generated and an invalid GPUComputePipeline object is returned:
module referenced inside the compute property is less than or equal to the GPUDevice's maxComputeWorkgroupStorageSize limit.module uses a number of compute invocations per workgroup less than or equal to the GPUDevice's maxComputeInvocationsPerWorkgroup limit.module's workgroup size is less than or equal to the GPUDevice's corresponding maxComputeWorkgroupSizeX, maxComputeWorkgroupSizeY, or maxComputeWorkgroupSizeZ limit.entryPoint property is omitted, the shader code contains a single compute shader entry point function for the browser to use as the default entry point.Note: The WebGPU samples feature many more examples.
Our basic compute demo shows a process of:
GPUDevice.createBindGroupLayout().bindGroupLayout into GPUDevice.createPipelineLayout() to create a GPUPipelineLayout.createComputePipeline() call to create a GPUComputePipeline.// …
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",
},
});
// …
| Specification |
|---|
| WebGPU> # dom-gpudevice-createcomputepipeline> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
createComputePipeline |
113Currently supported on ChromeOS, macOS, and Windows only. |
113Currently supported on ChromeOS, macOS, and Windows only. |
141Currently supported on Windows only, in all contexts except for service workers. |
99Currently supported on ChromeOS, macOS, and Windows only. |
26 | 121 | No | 81 | 26 | 25.0 | 121 | 26 |
optional_entryPoint |
121Currently supported on ChromeOS, macOS, and Windows only. |
121Currently supported on ChromeOS, macOS, and Windows only. |
No | 107Currently supported on ChromeOS, macOS, and Windows only. |
No | 121Currently supported on ChromeOS, macOS, and Windows only. |
No | 81Currently supported on ChromeOS, macOS, and Windows only. |
No | 25.0Currently supported on ChromeOS, macOS, and Windows only. |
121Currently supported on ChromeOS, macOS, and Windows only. |
No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createComputePipeline