diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 847ceff..bddddca 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -1,5 +1,6 @@ import BatchGeometry from './BatchGeometry'; import BatchDrawCall from './BatchDrawCall'; +import BaseTexture from '../textures/BaseTexture'; import State from '../state/State'; import ObjectRenderer from './ObjectRenderer'; @@ -12,8 +13,6 @@ import generateMultiTextureShader from './generateMultiTextureShader'; import { ENV } from '@pixi/constants'; -let TICK = 0; - /** * Renderer dedicated to drawing and batching sprites. * @@ -251,7 +250,7 @@ currentGroup.start = 0; currentGroup.blend = blendMode; - TICK++; + let TICK = ++BaseTexture._globalBatch; let i; @@ -282,7 +281,7 @@ { currentTexture = nextTexture; - if (nextTexture._enabled !== TICK) + if (nextTexture._batchEnabled !== TICK) { if (textureCount === MAX_TEXTURES) { @@ -299,7 +298,7 @@ } nextTexture.touched = touch; - nextTexture._enabled = TICK; + nextTexture._batchEnabled = TICK; nextTexture._id = textureCount; currentGroup.textures[currentGroup.textureCount++] = nextTexture; @@ -314,6 +313,8 @@ indexCount += sprite.indices.length; } + BaseTexture._globalBatch = TICK; + currentGroup.size = indexCount - currentGroup.start; // this.indexBuffer.update(); diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 847ceff..bddddca 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -1,5 +1,6 @@ import BatchGeometry from './BatchGeometry'; import BatchDrawCall from './BatchDrawCall'; +import BaseTexture from '../textures/BaseTexture'; import State from '../state/State'; import ObjectRenderer from './ObjectRenderer'; @@ -12,8 +13,6 @@ import generateMultiTextureShader from './generateMultiTextureShader'; import { ENV } from '@pixi/constants'; -let TICK = 0; - /** * Renderer dedicated to drawing and batching sprites. * @@ -251,7 +250,7 @@ currentGroup.start = 0; currentGroup.blend = blendMode; - TICK++; + let TICK = ++BaseTexture._globalBatch; let i; @@ -282,7 +281,7 @@ { currentTexture = nextTexture; - if (nextTexture._enabled !== TICK) + if (nextTexture._batchEnabled !== TICK) { if (textureCount === MAX_TEXTURES) { @@ -299,7 +298,7 @@ } nextTexture.touched = touch; - nextTexture._enabled = TICK; + nextTexture._batchEnabled = TICK; nextTexture._id = textureCount; currentGroup.textures[currentGroup.textureCount++] = nextTexture; @@ -314,6 +313,8 @@ indexCount += sprite.indices.length; } + BaseTexture._globalBatch = TICK; + currentGroup.size = indexCount - currentGroup.start; // this.indexBuffer.update(); diff --git a/packages/core/src/textures/BaseTexture.js b/packages/core/src/textures/BaseTexture.js index 4d4dbf0..98573ff 100644 --- a/packages/core/src/textures/BaseTexture.js +++ b/packages/core/src/textures/BaseTexture.js @@ -142,7 +142,7 @@ this.uid = uid(); /** - * TODO: fill in description + * Used by automatic texture Garbage Collection, stores last GC tick when it was bound * * @member {number} * @protected @@ -226,6 +226,13 @@ this.resource = null; /** + * Number of the texture batch, used by multi-texture renderers + * + * @member {number} + */ + this._batchEnabled = 0; + + /** * Fired when a not-immediately-available source finishes loading. * * @protected @@ -633,3 +640,11 @@ return null; } } + +/** + * Global number of the texture batch, used by multi-texture renderers + * + * @static + * @member {number} new texture batch number + */ +BaseTexture._globalBatch = 0; diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 847ceff..bddddca 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -1,5 +1,6 @@ import BatchGeometry from './BatchGeometry'; import BatchDrawCall from './BatchDrawCall'; +import BaseTexture from '../textures/BaseTexture'; import State from '../state/State'; import ObjectRenderer from './ObjectRenderer'; @@ -12,8 +13,6 @@ import generateMultiTextureShader from './generateMultiTextureShader'; import { ENV } from '@pixi/constants'; -let TICK = 0; - /** * Renderer dedicated to drawing and batching sprites. * @@ -251,7 +250,7 @@ currentGroup.start = 0; currentGroup.blend = blendMode; - TICK++; + let TICK = ++BaseTexture._globalBatch; let i; @@ -282,7 +281,7 @@ { currentTexture = nextTexture; - if (nextTexture._enabled !== TICK) + if (nextTexture._batchEnabled !== TICK) { if (textureCount === MAX_TEXTURES) { @@ -299,7 +298,7 @@ } nextTexture.touched = touch; - nextTexture._enabled = TICK; + nextTexture._batchEnabled = TICK; nextTexture._id = textureCount; currentGroup.textures[currentGroup.textureCount++] = nextTexture; @@ -314,6 +313,8 @@ indexCount += sprite.indices.length; } + BaseTexture._globalBatch = TICK; + currentGroup.size = indexCount - currentGroup.start; // this.indexBuffer.update(); diff --git a/packages/core/src/textures/BaseTexture.js b/packages/core/src/textures/BaseTexture.js index 4d4dbf0..98573ff 100644 --- a/packages/core/src/textures/BaseTexture.js +++ b/packages/core/src/textures/BaseTexture.js @@ -142,7 +142,7 @@ this.uid = uid(); /** - * TODO: fill in description + * Used by automatic texture Garbage Collection, stores last GC tick when it was bound * * @member {number} * @protected @@ -226,6 +226,13 @@ this.resource = null; /** + * Number of the texture batch, used by multi-texture renderers + * + * @member {number} + */ + this._batchEnabled = 0; + + /** * Fired when a not-immediately-available source finishes loading. * * @protected @@ -633,3 +640,11 @@ return null; } } + +/** + * Global number of the texture batch, used by multi-texture renderers + * + * @static + * @member {number} new texture batch number + */ +BaseTexture._globalBatch = 0; diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index 04d6f2d..18d2f84 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,6 +1,6 @@ import { SHAPES } from '@pixi/math'; import { Bounds } from '@pixi/display'; -import { BatchGeometry, BatchDrawCall } from '@pixi/core'; +import { BatchGeometry, BatchDrawCall, BaseTexture } from '@pixi/core'; import { DRAW_MODES } from '@pixi/constants'; import GraphicsData from './GraphicsData'; @@ -14,7 +14,6 @@ const BATCH_POOL = []; const DRAW_CALL_POOL = []; -let TICK = 0; /** * Map of fill commands for each shape type. * @@ -580,7 +579,7 @@ */ buildDrawCalls() { - TICK++; + let TICK = ++BaseTexture._globalBatch; for (let i = 0; i < this.drawCalls.length; i++) { @@ -638,7 +637,7 @@ { currentTexture = nextTexture; - if (nextTexture._enabled !== TICK) + if (nextTexture._batchEnabled !== TICK) { if (textureCount === MAX_TEXTURES) { @@ -660,7 +659,7 @@ // TODO add this to the render part.. nextTexture.touched = 1;// touch; - nextTexture._enabled = TICK; + nextTexture._batchEnabled = TICK; nextTexture._id = textureCount; nextTexture.wrapMode = 10497; @@ -678,6 +677,8 @@ this.addTextureIds(textureIds, textureId, data.attribSize); } + BaseTexture._globalBatch = TICK; + // upload.. // merge for now! const verts = this.points;