Skip to content

Commit

Permalink
WebGPURenderer: fix occlusion when rendering to a texture with WebGL …
Browse files Browse the repository at this point in the history
…fallback (mrdoob#29154)

Co-authored-by: aardgoose <angus.sawyer@email.com>
  • Loading branch information
aardgoose and aardgoose authored Aug 16, 2024
1 parent 4046207 commit 5db8c83
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -250,7 +264,6 @@ class WebGLBackend extends Backend {

this._currentContext = previousContext;


if ( renderContext.textures !== null && renderContext.renderTarget ) {

const renderTargetContextData = this.get( renderContext.renderTarget );
Expand Down Expand Up @@ -288,7 +301,6 @@ class WebGLBackend extends Backend {

}


}

}
Expand All @@ -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 );

}
Expand Down

0 comments on commit 5db8c83

Please sign in to comment.