Skip to content

Commit 8797943

Browse files
authored
remove _forceViewport (#31189)
1 parent 2dba5a8 commit 8797943

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/renderers/common/Renderer.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ class Renderer {
314314
*/
315315
this._scissor = new Vector4( 0, 0, this._width, this._height );
316316

317-
this._forceViewport = false;
318-
319317
/**
320318
* Whether the scissor test should be enabled or not.
321319
*
@@ -1245,7 +1243,16 @@ class Renderer {
12451243

12461244
frameBufferTarget.depthBuffer = depth;
12471245
frameBufferTarget.stencilBuffer = stencil;
1248-
frameBufferTarget.setSize( width, height, outputRenderTarget !== null ? outputRenderTarget.depth : 1 );
1246+
if ( outputRenderTarget !== null ) {
1247+
1248+
frameBufferTarget.setSize( outputRenderTarget.width, outputRenderTarget.height, outputRenderTarget.depth );
1249+
1250+
} else {
1251+
1252+
frameBufferTarget.setSize( width, height, 1 );
1253+
1254+
}
1255+
12491256
frameBufferTarget.viewport.copy( this._viewport );
12501257
frameBufferTarget.scissor.copy( this._scissor );
12511258
frameBufferTarget.viewport.multiplyScalar( this._pixelRatio );
@@ -1383,7 +1390,7 @@ class Renderer {
13831390
renderContext.viewportValue.height >>= activeMipmapLevel;
13841391
renderContext.viewportValue.minDepth = minDepth;
13851392
renderContext.viewportValue.maxDepth = maxDepth;
1386-
renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false || this._forceViewport;
1393+
renderContext.viewport = renderContext.viewportValue.equals( _screen ) === false;
13871394

13881395
renderContext.scissorValue.copy( scissor ).multiplyScalar( pixelRatio ).floor();
13891396
renderContext.scissor = this._scissorTest && renderContext.scissorValue.equals( _screen ) === false;
@@ -1513,8 +1520,6 @@ class Renderer {
15131520
this._width = width;
15141521
this._height = height;
15151522

1516-
this._forceViewport = true;
1517-
15181523
this.setViewport( 0, 0, width, height );
15191524

15201525
}
@@ -1702,7 +1707,6 @@ class Renderer {
17021707

17031708
this.domElement.width = Math.floor( width * pixelRatio );
17041709
this.domElement.height = Math.floor( height * pixelRatio );
1705-
this._forceViewport = false;
17061710

17071711
this.setViewport( 0, 0, width, height );
17081712

@@ -1728,8 +1732,6 @@ class Renderer {
17281732
this.domElement.width = Math.floor( width * this._pixelRatio );
17291733
this.domElement.height = Math.floor( height * this._pixelRatio );
17301734

1731-
this._forceViewport = false;
1732-
17331735
if ( updateStyle === true ) {
17341736

17351737
this.domElement.style.width = width + 'px';

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
1313

1414
import { warnOnce } from '../../utils.js';
1515
import { WebGLCoordinateSystem } from '../../constants.js';
16+
import { Vector2 } from '../../math/Vector2.js';
1617
import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
1718

19+
const _drawingBufferSize = /*@__PURE__*/ new Vector2();
20+
1821
/**
1922
* A backend implementation targeting WebGL 2.
2023
*
@@ -441,7 +444,7 @@ class WebGLBackend extends Backend {
441444
*/
442445
beginRender( renderContext ) {
443446

444-
const { state, gl } = this;
447+
const { state } = this;
445448
const renderContextData = this.get( renderContext );
446449

447450
//
@@ -452,7 +455,8 @@ class WebGLBackend extends Backend {
452455

453456
} else {
454457

455-
state.viewport( 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight );
458+
const { width, height } = this.getDrawingBufferSize( _drawingBufferSize );
459+
state.viewport( 0, 0, width, height );
456460

457461
}
458462

@@ -611,7 +615,8 @@ class WebGLBackend extends Backend {
611615

612616
} else {
613617

614-
state.viewport( 0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight );
618+
const { width, height } = this.getDrawingBufferSize( _drawingBufferSize );
619+
state.viewport( 0, 0, width, height );
615620

616621
}
617622

0 commit comments

Comments
 (0)