File tree Expand file tree Collapse file tree 4 files changed +40
-3
lines changed
Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,16 @@ class BufferGeometry extends EventDispatcher {
111111 */
112112 this . indirect = null ;
113113
114+ /**
115+ * The offset, in bytes, into the indirect drawing buffer where the value data begins.
116+ *
117+ * Can only be used with {@link WebGPURenderer} and a WebGPU backend.
118+ *
119+ * @type {number }
120+ * @default 0
121+ */
122+ this . indirectOffset = 0 ;
123+
114124 /**
115125 * This dictionary has as id the name of the attribute to be set and as value
116126 * the buffer attribute to set it to. Rather than accessing this property directly,
@@ -224,11 +234,13 @@ class BufferGeometry extends EventDispatcher {
224234 * Sets the given indirect attribute to this geometry.
225235 *
226236 * @param {BufferAttribute } indirect - The attribute holding indirect draw calls.
237+ * @param {number } [indirectOffset=0] - The offset, in bytes, into the indirect drawing buffer where the value data begins.
227238 * @return {BufferGeometry } A reference to this instance.
228239 */
229- setIndirect ( indirect ) {
240+ setIndirect ( indirect , indirectOffset = 0 ) {
230241
231242 this . indirect = indirect ;
243+ this . indirectOffset = indirectOffset ;
232244
233245 return this ;
234246
Original file line number Diff line number Diff line change @@ -310,6 +310,18 @@ class Geometries extends DataMap {
310310
311311 }
312312
313+ /**
314+ * Returns the byte offset into the indirect attribute buffer of the given render object.
315+ *
316+ * @param {RenderObject } renderObject - The render object.
317+ * @return {number } The byte offset into the indirect attribute buffer.
318+ */
319+ getIndirectOffset ( renderObject ) {
320+
321+ return renderObject . geometry . indirectOffset ;
322+
323+ }
324+
313325 /**
314326 * Returns the index of the given render object's geometry. This is implemented
315327 * in a method to return a wireframe index if necessary.
Original file line number Diff line number Diff line change @@ -444,6 +444,17 @@ class RenderObject {
444444
445445 }
446446
447+ /**
448+ * Returns the byte offset into the indirect attribute buffer.
449+ *
450+ * @return {number } The byte offset into the indirect attribute buffer.
451+ */
452+ getIndirectOffset ( ) {
453+
454+ return this . _geometries . getIndirectOffset ( this ) ;
455+
456+ }
457+
447458 /**
448459 * Returns an array that acts as a key for identifying the render object in a chain map.
449460 *
Original file line number Diff line number Diff line change @@ -1600,8 +1600,9 @@ class WebGPUBackend extends Backend {
16001600 if ( indirect !== null ) {
16011601
16021602 const buffer = this . get ( indirect ) . buffer ;
1603+ const indirectOffset = renderObject . getIndirectOffset ( ) ;
16031604
1604- passEncoderGPU . drawIndexedIndirect ( buffer , 0 ) ;
1605+ passEncoderGPU . drawIndexedIndirect ( buffer , indirectOffset ) ;
16051606
16061607 } else {
16071608
@@ -1620,8 +1621,9 @@ class WebGPUBackend extends Backend {
16201621 if ( indirect !== null ) {
16211622
16221623 const buffer = this . get ( indirect ) . buffer ;
1624+ const indirectOffset = renderObject . getIndirectOffset ( ) ;
16231625
1624- passEncoderGPU . drawIndirect ( buffer , 0 ) ;
1626+ passEncoderGPU . drawIndirect ( buffer , indirectOffset ) ;
16251627
16261628 } else {
16271629
You can’t perform that action at this time.
0 commit comments