Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/BufferGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class BufferGeometry extends EventDispatcher {
this.indirect = null;

/**
* The offset, in bytes, into the indirect drawing buffer where the value data begins.
* The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.
*
* Can only be used with {@link WebGPURenderer} and a WebGPU backend.
*
* @type {number}
* @type {number|Array<number>}
* @default 0
*/
this.indirectOffset = 0;
Expand Down Expand Up @@ -234,7 +234,7 @@ class BufferGeometry extends EventDispatcher {
* Sets the given indirect attribute to this geometry.
*
* @param {BufferAttribute} indirect - The attribute holding indirect draw calls.
* @param {number} [indirectOffset=0] - The offset, in bytes, into the indirect drawing buffer where the value data begins.
* @param {number|Array<number>} [indirectOffset=0] - The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.
* @return {BufferGeometry} A reference to this instance.
*/
setIndirect( indirect, indirectOffset = 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/RenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class RenderObject {
/**
* Returns the byte offset into the indirect attribute buffer.
*
* @return {number} The byte offset into the indirect attribute buffer.
* @return {number|Array<number>} The byte offset into the indirect attribute buffer.
*/
getIndirectOffset() {

Expand Down
15 changes: 13 additions & 2 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1601,8 +1601,13 @@ class WebGPUBackend extends Backend {

const buffer = this.get( indirect ).buffer;
const indirectOffset = renderObject.getIndirectOffset();
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];

passEncoderGPU.drawIndexedIndirect( buffer, indirectOffset );
for ( let i = 0; i < indirectOffsets.length; i ++ ) {

passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );

}

} else {

Expand All @@ -1622,8 +1627,14 @@ class WebGPUBackend extends Backend {

const buffer = this.get( indirect ).buffer;
const indirectOffset = renderObject.getIndirectOffset();
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];

for ( let i = 0; i < indirectOffsets.length; i ++ ) {

passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );

}

passEncoderGPU.drawIndirect( buffer, indirectOffset );

} else {

Expand Down