Get to know MDN better
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 beginRenderPass() method of the GPUCommandEncoder interface starts encoding a render pass, returning a GPURenderPassEncoder that can be used to control rendering.
An object containing the following properties:
colorAttachmentsAn array of objects (see Color attachment object structure) defining the color attachments that will be output to when executing this render pass.
depthStencilAttachment OptionalAn object (see Depth/stencil attachment object structure) defining the depth/stencil attachment that will be output to and tested against when executing this render pass.
label OptionalA string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.
maxDrawCount OptionalA number indicating the maximum number of draw calls that will be done in the render pass. This is used by some implementations to size work injected before the render pass. You should keep the default value — 50000000 — unless you know that more draw calls will be done.
occlusionQuerySet OptionalThe GPUQuerySet that will store the occlusion query results for this pass.
timestampWrites OptionalAn array of objects defining where and when timestamp query values will be written for this pass. These objects have the following properties:
querySetA GPUQuerySet of type "timestamp" that the timestamp query results will be written to.
beginningOfPassWriteIndexA number specifying the query index in querySet where the timestamp at the beginning of the render pass will be written. This is optional - if not defined, no timestamp will be written for the beginning of the pass.
endOfPassWriteIndexA number specifying the query index in querySet where the timestamp at the end of the render pass will be written. This is optional - if not defined, no timestamp will be written for the end of the pass.
Note: The timestamp-query feature needs to be enabled to use timestamp queries. Timestamp query values are written in nanoseconds, but how the value is determined is implementation-defined.
Color attachment objects can have the following properties:
clearValue OptionalA color value to clear the view texture to, prior to executing the render pass. This value is ignored if loadOp is not set to "clear". clearValue takes an array or object representing the four color components r, g, b, and a as decimals.
For example, you can pass an array like [0.0, 0.5, 1.0, 1.0], or its equivalent object { r: 0.0, g: 0.5, b: 1.0, a: 1.0 }.
If clearValue is omitted, it defaults to { r: 0, g: 0, b: 0, a: 0 }.
depthSlice OptionalA number representing the index of the 3D depth slice that will be output to for this color attachment, in the case of a 3D GPUTextureView view. When specified, this allows WebGPU to render directly to slices of 3D textures within render passes.
loadOpAn enumerated value indicating the load operation to perform on view prior to executing the render pass. Possible values are:
Note: It is recommended to always use "clear" in cases where the initial value doesn't matter, as it will give better performance on some devices such as mobiles.
An enumerated value indicating the store operation to perform on view after executing the render pass. Possible values are:
An object representing the texture subresource that will receive the resolved output for this color attachment if view is multisampled. This can be one of the following:
An object representing the texture subresource that will be output to for this color attachment. This can be one of the following:
Note: Each color or depth/stencil attachment must be a unique texture subresource, and texture subresources used as attachments cannot be used inside the render pass.
The depthStencilAttachment object can have the following properties:
depthClearValue OptionalA number indicating the value to clear view's depth component prior to executing the render pass. This is ignored if depthLoadOp is not set to "clear".
The value must be between 0.0 and 1.0, inclusive.
depthLoadOp OptionalAn enumerated value indicating the load operation to perform on view's depth component prior to executing the render pass. Possible values are:
Note: It is recommended to always use "clear" in cases where the initial value doesn't matter, as it will give better performance on some devices such as mobiles.
A boolean. Setting the value to true causes the depth component of view to be read-only. If depthReadOnly is omitted, it defaults to false.
depthStoreOp OptionalAn enumerated value indicating the store operation to perform on view's depth component after executing the render pass. Possible values are:
A number indicating the value to clear view's stencil component to prior to executing the render pass. This is ignored if stencilLoadOp is not set to "clear".
If stencilClearValue is omitted, it defaults to 0.
stencilLoadOp OptionalAn enumerated value indicating the load operation to perform on view's stencil component prior to executing the render pass. Possible values are:
Note: It is recommended to always use "clear" in cases where the initial value doesn't matter, as it will give better performance on some devices such as mobiles.
A boolean. Setting the value to true causes the stencil component of view to be read-only. If stencilReadOnly is omitted, it defaults to false.
stencilStoreOp OptionalAn enumerated value indicating the store operation to perform on view's stencil component after executing the render pass. Possible values are:
An object representing the texture subresource that will be output to and read from for this depth/stencil attachment. This can be one of the following:
A GPURenderPassEncoder object instance.
The following criteria must be met when calling beginRenderPass(), otherwise a GPUValidationError is generated and an invalid GPURenderPassEncoder is returned.
General:
For color attachment objects
For depth/stencil attachment objects:
For timestamp queries:
In our basic render demo, a number of commands are recorded via a GPUCommandEncoder. These commands originate from the GPURenderPassEncoder created via beginRenderPass() :
| WebGPU # dom-gpucommandencoder-beginrenderpass |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 14, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.