Skip to content

Commit a593f54

Browse files
authored
WebGPURenderer: Fix runtime errors introduced by texture array refactor. (#31108)
* fix runtime errors introduced by texture array refactor * add render pass for xr layers
1 parent 088df26 commit a593f54

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/core/RenderTarget.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,7 @@ class RenderTarget extends EventDispatcher {
294294
this.textures[ i ].image.width = width;
295295
this.textures[ i ].image.height = height;
296296
this.textures[ i ].image.depth = depth;
297-
298-
if ( this.textures[ i ].image.depth > 1 ) {
299-
300-
this.textures[ i ].isArrayTexture = true;
301-
302-
}
297+
this.textures[ i ].isArrayTexture = this.textures[ i ].image.depth > 1;
303298

304299
}
305300

src/renderers/common/XRManager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ class XRManager extends EventDispatcher {
786786
const quaternionObject = new Quaternion();
787787

788788
const wasPresenting = this.isPresenting;
789+
const rendererOutputTarget = this._renderer.getOutputRenderTarget();
790+
const rendererFramebufferTarget = this._renderer._frameBufferTarget;
789791
this.isPresenting = false;
790792

791793
for ( const layer of this._layers ) {
@@ -804,6 +806,8 @@ class XRManager extends EventDispatcher {
804806
glSubImage.colorTexture,
805807
glSubImage.depthStencilTexture );
806808

809+
this._renderer.setOutputRenderTarget( layer.renderTarget );
810+
807811
}
808812

809813
this._renderer.setRenderTarget( layer.renderTarget );
@@ -813,6 +817,8 @@ class XRManager extends EventDispatcher {
813817

814818
this.isPresenting = wasPresenting;
815819
this._renderer.setRenderTarget( null );
820+
this._renderer.setOutputRenderTarget( rendererOutputTarget );
821+
this._renderer._frameBufferTarget = rendererFramebufferTarget;
816822

817823
}
818824

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,19 +2054,19 @@ class WebGLBackend extends Backend {
20542054

20552055
const attachment = gl.COLOR_ATTACHMENT0 + i;
20562056

2057-
if ( isRenderTarget3D || isRenderTargetArray ) {
2057+
if ( renderTarget.multiview ) {
2058+
2059+
multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, samples, 0, 2 );
2060+
2061+
} else if ( isRenderTarget3D || isRenderTargetArray ) {
20582062

20592063
const layer = this.renderer._activeCubeFace;
20602064

20612065
gl.framebufferTextureLayer( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, layer );
20622066

20632067
} else {
20642068

2065-
if ( renderTarget.multiview ) {
2066-
2067-
multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, samples, 0, 2 );
2068-
2069-
} else if ( hasExternalTextures && useMultisampledRTT ) {
2069+
if ( hasExternalTextures && useMultisampledRTT ) {
20702070

20712071
multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );
20722072

0 commit comments

Comments
 (0)