Skip to content

Commit

Permalink
WebGPURenderer: Add "updateRanges" support for WebGLAttributeUtils (#…
Browse files Browse the repository at this point in the history
…27149)

* Add "updateRanges" support for WebGLAttributeUtils

* Fix failed test
  • Loading branch information
gkjohnson committed Nov 17, 2023
1 parent 5f53c76 commit 763c53e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,30 @@ class WebGLAttributeUtils {
const bufferAttribute = attribute.isInterleavedBufferAttribute ? attribute.data : attribute;
const bufferData = backend.get( bufferAttribute );
const bufferType = bufferData.bufferType;
const updateRanges = attribute.isInterleavedBufferAttribute ? attribute.data.updateRanges : attribute.updateRanges;

gl.bindBuffer( bufferType, bufferData.bufferGPU );
gl.bufferSubData( bufferType, 0, array );

if ( updateRanges.length === 0 ) {

// Not using update ranges

gl.bufferSubData( bufferType, 0, array );

} else {

for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {

const range = updateRanges[ i ];
gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
array, range.start, range.count );

}

bufferAttribute.clearUpdateRanges();

}

gl.bindBuffer( bufferType, null );

bufferData.version = bufferAttribute.version;
Expand Down

0 comments on commit 763c53e

Please sign in to comment.