diff --git a/src/renderers/webgl-fallback/WebGLBackend.js b/src/renderers/webgl-fallback/WebGLBackend.js index 75e99e420b6626..a89bb1ebfd4993 100644 --- a/src/renderers/webgl-fallback/WebGLBackend.js +++ b/src/renderers/webgl-fallback/WebGLBackend.js @@ -230,6 +230,20 @@ class WebGLBackend extends Backend { const renderContextData = this.get( renderContext ); const previousContext = renderContextData.previousContext; + const occlusionQueryCount = renderContext.occlusionQueryCount; + + if ( occlusionQueryCount > 0 ) { + + if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) { + + gl.endQuery( gl.ANY_SAMPLES_PASSED ); + + } + + this.resolveOccludedAsync( renderContext ); + + } + const textures = renderContext.textures; if ( textures !== null ) { @@ -250,7 +264,6 @@ class WebGLBackend extends Backend { this._currentContext = previousContext; - if ( renderContext.textures !== null && renderContext.renderTarget ) { const renderTargetContextData = this.get( renderContext.renderTarget ); @@ -288,7 +301,6 @@ class WebGLBackend extends Backend { } - } } @@ -306,32 +318,12 @@ class WebGLBackend extends Backend { } else { - const gl = this.gl; - gl.viewport( 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight ); } } - const occlusionQueryCount = renderContext.occlusionQueryCount; - - if ( occlusionQueryCount > 0 ) { - - const renderContextData = this.get( renderContext ); - - if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) { - - const { gl } = this; - - gl.endQuery( gl.ANY_SAMPLES_PASSED ); - - } - - this.resolveOccludedAsync( renderContext ); - - } - this.prepareTimestampBuffer( renderContext ); }