|
|
@@ -498,6 +498,8 @@ class WebGLBackend extends Backend {
|
|
|
const renderContextData = this.get( renderContext );
|
|
|
const previousContext = renderContextData.previousContext;
|
|
|
|
|
|
+ state.resetVertexState();
|
|
|
+
|
|
|
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
|
|
|
|
if ( occlusionQueryCount > 0 ) {
|
|
|
@@ -854,17 +856,17 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const { programGPU, transformBuffers, attributes } = this.get( pipeline );
|
|
|
|
|
|
- const vaoKey = this._getVaoKey( null, attributes );
|
|
|
+ const vaoKey = this._getVaoKey( attributes );
|
|
|
|
|
|
const vaoGPU = this.vaoCache[ vaoKey ];
|
|
|
|
|
|
if ( vaoGPU === undefined ) {
|
|
|
|
|
|
- this._createVao( null, attributes );
|
|
|
+ this._createVao( attributes );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- gl.bindVertexArray( vaoGPU );
|
|
|
+ state.setVertexState( vaoGPU );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -962,7 +964,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
state.useProgram( programGPU );
|
|
|
|
|
|
- //
|
|
|
+ // vertex state
|
|
|
|
|
|
const renderObjectData = this.get( renderObject );
|
|
|
|
|
|
@@ -970,7 +972,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
if ( vaoGPU === undefined || renderObjectData.geometryId !== renderObject.geometry.id ) {
|
|
|
|
|
|
- const vaoKey = this._getVaoKey( renderObject.getIndex(), renderObject.getAttributes() );
|
|
|
+ const vaoKey = this._getVaoKey( renderObject.getAttributes() );
|
|
|
|
|
|
vaoGPU = this.vaoCache[ vaoKey ];
|
|
|
|
|
|
@@ -978,7 +980,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
let staticVao;
|
|
|
|
|
|
- ( { vaoGPU, staticVao } = this._createVao( renderObject.getIndex(), renderObject.getAttributes() ) );
|
|
|
+ ( { vaoGPU, staticVao } = this._createVao( renderObject.getAttributes() ) );
|
|
|
|
|
|
if ( staticVao ) {
|
|
|
|
|
|
@@ -991,11 +993,10 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- gl.bindVertexArray( vaoGPU );
|
|
|
-
|
|
|
- //
|
|
|
-
|
|
|
const index = renderObject.getIndex();
|
|
|
+ const indexGPU = ( index !== null ) ? this.get( index ).bufferGPU : null;
|
|
|
+
|
|
|
+ state.setVertexState( vaoGPU, indexGPU );
|
|
|
|
|
|
//
|
|
|
|
|
|
@@ -1167,10 +1168,6 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
-
|
|
|
- gl.bindVertexArray( null );
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2149,22 +2146,13 @@ class WebGLBackend extends Backend {
|
|
|
* Computes the VAO key for the given index and attributes.
|
|
|
*
|
|
|
* @private
|
|
|
- * @param {?BufferAttribute} index - The index. `null` for non-indexed geometries.
|
|
|
* @param {Array<BufferAttribute>} attributes - An array of buffer attributes.
|
|
|
* @return {string} The VAO key.
|
|
|
*/
|
|
|
- _getVaoKey( index, attributes ) {
|
|
|
+ _getVaoKey( attributes ) {
|
|
|
|
|
|
let key = '';
|
|
|
|
|
|
- if ( index !== null ) {
|
|
|
-
|
|
|
- const indexData = this.get( index );
|
|
|
-
|
|
|
- key += ':' + indexData.id;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
for ( let i = 0; i < attributes.length; i ++ ) {
|
|
|
|
|
|
const attributeData = this.get( attributes[ i ] );
|
|
|
@@ -2181,11 +2169,10 @@ class WebGLBackend extends Backend {
|
|
|
* Creates a VAO from the index and attributes.
|
|
|
*
|
|
|
* @private
|
|
|
- * @param {?BufferAttribute} index - The index. `null` for non-indexed geometries.
|
|
|
* @param {Array<BufferAttribute>} attributes - An array of buffer attributes.
|
|
|
* @return {Object} The VAO data.
|
|
|
*/
|
|
|
- _createVao( index, attributes ) {
|
|
|
+ _createVao( attributes ) {
|
|
|
|
|
|
const { gl } = this;
|
|
|
|
|
|
@@ -2196,16 +2183,6 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
gl.bindVertexArray( vaoGPU );
|
|
|
|
|
|
- if ( index !== null ) {
|
|
|
-
|
|
|
- const indexData = this.get( index );
|
|
|
-
|
|
|
- gl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, indexData.bufferGPU );
|
|
|
-
|
|
|
- key += ':' + indexData.id;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
for ( let i = 0; i < attributes.length; i ++ ) {
|
|
|
|
|
|
const attribute = attributes[ i ];
|