WebGPU API
The drawIndexed() method of the
GPURenderBundleEncoder interface draws indexed primitives based on the vertex and index buffers provided by GPURenderBundleEncoder.setVertexBuffer and GPURenderBundleEncoder.setIndexBuffer.
[!NOTE] This method is functionally identical to its equivalent on GPURenderPassEncoder — GPURenderPassEncoder.drawIndexed.
Syntax
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- : A number defining the number of instances to draw. If omitted,
instanceCountdefaults to 1.
- : A number defining the number of instances to draw. If omitted,
firstIndex- : A number defining the offset into the index buffer, in indices, to begin drawing from. If omitted,
firstIndexdefaults to 0.
- : A number defining the offset into the index buffer, in indices, to begin drawing from. If omitted,
baseVertex- : A number added to each index value before indexing into the vertex buffers. If omitted,
baseVertexdefaults to 0.
- : A number added to each index value before indexing into the vertex buffers. If omitted,
firstInstance- : A number defining the first instance to draw. If omitted,
firstInstancedefaults to 0.
- : A number defining the first instance to draw. If omitted,
Return value
None (undefined).
Examples
// …
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
See also
- The WebGPU API
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
