WebGLRenderer.textureFlush is a new property that keeps track of the total texture flushes per frame.

This commit is contained in:
Richard Davey 2020-07-17 16:36:18 +01:00
parent a310bd08c0
commit 8d976d6ed5

View file

@ -604,6 +604,15 @@ var WebGLRenderer = new Class({
*/
this.mipmapFilter = null;
/**
* The number of times the renderer had to flush this frame, due to running out of texture units.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#textureFlush
* @type {number}
* @since 3.25.0
*/
this.textureFlush = 0;
this.init(this.config);
},
@ -1402,14 +1411,16 @@ var WebGLRenderer = new Class({
this.startActiveTexture++;
this.textureFlush++;
textureSource.glIndexCounter = this.startActiveTexture;
textureSource.glIndex = 0;
textureSource.glIndex = 1;
gl.activeTexture(gl.TEXTURE0);
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, textureSource.glTexture);
this.currentActiveTexture = 1;
this.currentActiveTexture = 2;
}
}
@ -1506,6 +1517,8 @@ var WebGLRenderer = new Class({
this.normalTexture = null;
this.startActiveTexture++;
this.currentActiveTexture = 1;
this.textureFlush++;
},
/**
@ -1534,6 +1547,8 @@ var WebGLRenderer = new Class({
this.currentActiveTexture = 1;
this.startActiveTexture++;
this.textureFlush++;
},
/**
@ -1573,6 +1588,8 @@ var WebGLRenderer = new Class({
this.startActiveTexture++;
this.textureFlush++;
texture.glIndexCounter = this.startActiveTexture;
texture.glIndex = 1;
@ -2308,6 +2325,8 @@ var WebGLRenderer = new Class({
this.currentCameraMask.mask = null;
this.maskStack.length = 0;
this.textureFlush = 0;
this.setPipeline(this.pipelines.TextureTintPipeline);
},
@ -2448,6 +2467,12 @@ var WebGLRenderer = new Class({
{
pipelines[key].onPostRender();
}
if (this.textureFlush > 0)
{
this.startActiveTexture++;
this.currentActiveTexture = 1;
}
},
/**