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 drawIndexedIndirect() method of the GPURenderBundleEncoder interface draws indexed primitives using parameters read from a GPUBuffer.
Note: This method is functionally identical to its equivalent on GPURenderPassEncoder — drawIndexedIndirect().
drawIndexedIndirect(indirectBuffer, indirectOffset)
indirectBufferA GPUBuffer containing the indexCount, instanceCount, firstIndex, baseVertex, and firstInstance values needed to carry out the drawing operation. The buffer must contain a tightly packed block of five 32-bit unsigned integer values representing the values (20 bytes total), given in the same order as the arguments for GPURenderBundleEncoder.drawIndexed(). So for example:
const uint32 = new Uint32Array(5); uint32[0] = 3; // The indexCount value uint32[1] = 1; // The instanceCount value uint32[2] = 0; // The firstIndex value uint32[3] = 0; // The baseVertex value uint32[4] = 0; // The firstInstance value // Write values into a GPUBuffer device.queue.writeBuffer(buffer, 0, uint32, 0, uint32.length);
Note: The indirect-first-instance feature needs to be enabled for non-zero firstInstance values to be used. If the indirect-first-instance feature is not enabled and firstInstance is not zero, the drawIndexedIndirect() call will be treated as a no-op.
indirectOffsetThe offset, in bytes, into indirectBuffer where the value data begins.
None (Undefined).
The following criteria must be met when calling drawIndirect(), otherwise a GPUValidationError is generated and the GPURenderBundleEncoder becomes invalid:
indirectBuffer's GPUBuffer.usage contains the GPUBufferUsage.INDIRECT flag.indirectOffset + the total size specified by the value parameters in the indirectBuffer is less than or equal to the indirectBuffer's GPUBuffer.size.indirectOffset is a multiple of 4.// …
// Create GPURenderBundleEncoder
const bundleEncoder = device.createRenderBundleEncoder(descriptor);
// Set pipeline and vertex buffer
bundleEncoder.setPipeline(renderPipeline);
bundleEncoder.setVertexBuffer(0, vertexBuffer);
bundleEncoder.setIndexBuffer(indexBuffer, "uint16");
// Create drawIndexedIndirect values
const uint32 = new Uint32Array(5);
uint32[0] = 3;
uint32[1] = 1;
uint32[2] = 0;
uint32[3] = 0;
uint32[4] = 0;
// Create a GPUBuffer and write the draw values into it
const drawValues = device.createBuffer({
size: 20,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.INDIRECT,
});
device.queue.writeBuffer(drawValues, 0, uint32, 0, uint32.length);
// Draw the vertices
bundleEncoder.drawIndexedIndirect(drawValues, 0);
// End the bundle recording
const renderBundle = bundleEncoder.finish();
// …
| Specification |
|---|
| WebGPU> # dom-gpurendercommandsmixin-drawindexedindirect> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
drawIndexedIndirect |
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/GPURenderBundleEncoder/drawIndexedIndirect