WebGPU API
The GPUPipelineError interface of the WebGPU API describes a pipeline failure. This is the value received when a Promise returned by a GPUDevice.createComputePipelineAsync() or GPUDevice.createRenderPipelineAsync() call rejects.
Constructor
- GPUPipelineError.GPUPipelineError
- : Creates a new
GPUPipelineErrorobject instance.
- : Creates a new
Instance properties
Inherits properties from its parent, DOMException.
- GPUPipelineError.reason
- : An enumerated value that defines the reason the pipeline creation failed in a machine-readable way.
Examples
In the following snippet we are attempting to create a GPUComputePipeline using GPUDevice.createComputePipelineAsync(). However, we have misspelled our compute pipeline entryPoint as "maijn" (it should be "main"), therefore pipeline creation fails, and our catch block prints the resulting reason and error message to the console.
// …
let computePipeline;
try {
computePipeline = await device.createComputePipelineAsync({
layout: device.createPipelineLayout({
bindGroupLayouts: [bindGroupLayout],
}),
compute: {
module: shaderModule,
entryPoint: "maijn",
},
});
} catch (error) {
// error is a GPUPipelineError object instance
console.error(error.reason);
console.error(`Pipeline creation failed: ${error.message}`);
}
// …
In this case, the given reason is "Validation", and the message is "Entry point "maijn" doesn't exist in the shader module [ShaderModule]."
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
