Selaa lähdekoodia

WebGPURenderer: fix occlusion when rendering to a texture with WebGL fallback (#29154)

Co-authored-by: aardgoose <angus.sawyer@email.com>
aardgoose 1 vuosi sitten
vanhempi
sitoutus
5db8c8320a
1 muutettua tiedostoa jossa 14 lisäystä ja 22 poistoa
  1. 14 22
      src/renderers/webgl-fallback/WebGLBackend.js

+ 14 - 22
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 );
 
 	}

粤ICP备19079148号