|
@@ -15655,12 +15655,48 @@ function WebGLBufferRenderer( gl, extensions, info ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
|
|
+
|
|
|
|
+ if ( drawCount === 0 ) return;
|
|
|
|
+
|
|
|
|
+ const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
|
|
+
|
|
|
|
+ if ( extension === null ) {
|
|
|
|
+
|
|
|
|
+ for ( let i = 0; i < starts.length; i ++ ) {
|
|
|
|
+
|
|
|
|
+ renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
|
|
|
|
+
|
|
|
|
+ let elementCount = 0;
|
|
|
|
+ for ( let i = 0; i < drawCount; i ++ ) {
|
|
|
|
+
|
|
|
|
+ elementCount += counts[ i ];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for ( let i = 0; i < primcount.length; i ++ ) {
|
|
|
|
+
|
|
|
|
+ info.update( elementCount, mode, primcount[ i ] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//
|
|
//
|
|
|
|
|
|
this.setMode = setMode;
|
|
this.setMode = setMode;
|
|
this.render = render;
|
|
this.render = render;
|
|
this.renderInstances = renderInstances;
|
|
this.renderInstances = renderInstances;
|
|
this.renderMultiDraw = renderMultiDraw;
|
|
this.renderMultiDraw = renderMultiDraw;
|
|
|
|
+ this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -17571,6 +17607,41 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
|
|
|
|
+
|
|
|
|
+ if ( drawCount === 0 ) return;
|
|
|
|
+
|
|
|
|
+ const extension = extensions.get( 'WEBGL_multi_draw' );
|
|
|
|
+
|
|
|
|
+ if ( extension === null ) {
|
|
|
|
+
|
|
|
|
+ for ( let i = 0; i < starts.length; i ++ ) {
|
|
|
|
+
|
|
|
|
+ renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
|
|
|
|
+
|
|
|
|
+ let elementCount = 0;
|
|
|
|
+ for ( let i = 0; i < drawCount; i ++ ) {
|
|
|
|
+
|
|
|
|
+ elementCount += counts[ i ];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for ( let i = 0; i < primcount.length; i ++ ) {
|
|
|
|
+
|
|
|
|
+ info.update( elementCount, mode, primcount[ i ] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//
|
|
//
|
|
|
|
|
|
this.setMode = setMode;
|
|
this.setMode = setMode;
|
|
@@ -17578,6 +17649,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
|
|
this.render = render;
|
|
this.render = render;
|
|
this.renderInstances = renderInstances;
|
|
this.renderInstances = renderInstances;
|
|
this.renderMultiDraw = renderMultiDraw;
|
|
this.renderMultiDraw = renderMultiDraw;
|
|
|
|
+ this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -25576,7 +25648,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ( ignoreDepthValues === true ) {
|
|
|
|
|
|
+ if ( ignoreDepthValues === true && supportsInvalidateFramebuffer ) {
|
|
|
|
|
|
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, [ depthStyle ] );
|
|
_gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, [ depthStyle ] );
|
|
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
_gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
|
|
@@ -29009,7 +29081,15 @@ class WebGLRenderer {
|
|
|
|
|
|
if ( object.isBatchedMesh ) {
|
|
if ( object.isBatchedMesh ) {
|
|
|
|
|
|
- renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
|
|
|
|
+ if ( object._multiDrawInstances !== null ) {
|
|
|
|
+
|
|
|
|
+ renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
} else if ( object.isInstancedMesh ) {
|
|
} else if ( object.isInstancedMesh ) {
|
|
|
|
|
|
@@ -32780,6 +32860,7 @@ class BatchedMesh extends Mesh {
|
|
this._multiDrawCounts = new Int32Array( maxGeometryCount );
|
|
this._multiDrawCounts = new Int32Array( maxGeometryCount );
|
|
this._multiDrawStarts = new Int32Array( maxGeometryCount );
|
|
this._multiDrawStarts = new Int32Array( maxGeometryCount );
|
|
this._multiDrawCount = 0;
|
|
this._multiDrawCount = 0;
|
|
|
|
+ this._multiDrawInstances = null;
|
|
this._visibilityChanged = true;
|
|
this._visibilityChanged = true;
|
|
|
|
|
|
// Local matrix per geometry by using data texture
|
|
// Local matrix per geometry by using data texture
|
|
@@ -33221,6 +33302,28 @@ class BatchedMesh extends Mesh {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ getInstanceCountAt( id ) {
|
|
|
|
+
|
|
|
|
+ if ( this._multiDrawInstances === null ) return null;
|
|
|
|
+
|
|
|
|
+ return this._multiDrawInstances[ id ];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setInstanceCountAt( id, instanceCount ) {
|
|
|
|
+
|
|
|
|
+ if ( this._multiDrawInstances === null ) {
|
|
|
|
+
|
|
|
|
+ this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._multiDrawInstances[ id ] = instanceCount;
|
|
|
|
+
|
|
|
|
+ return id;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
// get bounding box and compute it if it doesn't exist
|
|
// get bounding box and compute it if it doesn't exist
|
|
getBoundingBoxAt( id, target ) {
|
|
getBoundingBoxAt( id, target ) {
|
|
|
|
|