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 setScissorRect() method of the GPURenderPassEncoder interface sets the scissor rectangle used during the rasterization stage. After transformation into viewport coordinates any fragments that fall outside the scissor rectangle will be discarded.
setScissorRect(x, y, width, height)
xA number representing the minimum X value of the scissor rectangle, in pixels.
yA number representing the minimum Y value of the scissor rectangle, in pixels.
widthA number representing the width of the scissor rectangle, in pixels.
heightA number representing the height of the scissor rectangle, in pixels.
Note: If a setScissorRect() call is not made, the default values are (0, 0, attachment width, attachment height) for each render pass.
None (Undefined).
The following criteria must be met when calling setViewport(), otherwise a GPUValidationError is generated and the GPURenderPassEncoder becomes invalid:
x + width is less than or equal to the width of the render pass's render attachments (see note below).y + height is less than or equal to the height of the render pass's render attachments (see note below).Note: See the color and depth/stencil attachments specified in the descriptor of GPUCommandEncoder.beginRenderPass(); the width and height are based on that of the GPUTexture that their views originate from.
In a typical canvas render, the following could be used to discard any rendering outside of the top-left quarter of the canvas:
passEncoder.setScissorRect(0, 0, canvas.width / 2, canvas.height / 2);
| Specification |
|---|
| WebGPU> # dom-gpurenderpassencoder-setscissorrect> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
setScissorRect |
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 |
© 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/GPURenderPassEncoder/setScissorRect