W3cubDocs

/Web APIs

GPURenderBundleEncoder: drawIndexed() method

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The drawIndexed() method of the GPURenderBundleEncoder interface draws indexed primitives based on the vertex and index buffers provided by setVertexBuffer() and setIndexBuffer().

Note: This method is functionally identical to its equivalent on GPURenderPassEncoderdrawIndexed().

Syntax

js

drawIndexed(indexCount)
drawIndexed(indexCount, instanceCount)
drawIndexed(indexCount, instanceCount, firstIndex)
drawIndexed(indexCount, instanceCount, firstIndex, baseVertex)
drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance)

Parameters

indexCount

A number defining the number of indices to draw.

instanceCount Optional

A number defining the number of instances to draw. If omitted, instanceCount defaults to 1.

firstIndex Optional

A number defining the offset into the index buffer, in indices, to begin drawing from. If omitted, firstIndex defaults to 0.

baseVertex Optional

A number added to each index value before indexing into the vertex buffers. If omitted, baseVertex defaults to 0.

firstInstance Optional

A number defining the first instance to draw. If omitted, firstInstance defaults to 0.

Return value

None (Undefined).

Examples

js

// ...

const bundleEncoder = device.createRenderBundleEncoder(descriptor);

bundleEncoder.setPipeline(pipeline);
bundleEncoder.setBindGroup(0, sceneBindGroupForRender);
bundleEncoder.setBindGroup(1, modelBindGroup);
bundleEncoder.setVertexBuffer(0, vertexBuffer);
bundleEncoder.setIndexBuffer(indexBuffer, "uint16");
bundleEncoder.drawIndexed(indexCount);

const renderBundle = bundleEncoder.finish();

// ...

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
drawIndexed
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPURenderBundleEncoder/drawIndexed