diff --git a/.gitignore b/.gitignore index 592e2f6..4d57452 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ # VSCode ignores .vscode +pixi.code-workspace diff --git a/.gitignore b/.gitignore index 592e2f6..4d57452 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ # VSCode ignores .vscode +pixi.code-workspace diff --git a/packages/core/src/geometry/GeometrySystem.js b/packages/core/src/geometry/GeometrySystem.js index 6c2188f..d8e3bfa 100644 --- a/packages/core/src/geometry/GeometrySystem.js +++ b/packages/core/src/geometry/GeometrySystem.js @@ -42,6 +42,11 @@ * @private */ this.cache = {}; + + /** + * A cache of currently bound buffer.. + */ + this.boundBuffers = {}; } /** @@ -197,7 +202,14 @@ const type = buffer.index ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER; const drawType = buffer.static ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW; - gl.bindBuffer(type, glBuffer.buffer); + if (this.boundBuffers[type] !== glBuffer) + { + this.boundBuffers[type] = glBuffer; + + gl.bindBuffer(type, glBuffer.buffer); + } + + this._boundBuffer = glBuffer; if (glBuffer.byteLength >= buffer.data.byteLength) { diff --git a/.gitignore b/.gitignore index 592e2f6..4d57452 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ # VSCode ignores .vscode +pixi.code-workspace diff --git a/packages/core/src/geometry/GeometrySystem.js b/packages/core/src/geometry/GeometrySystem.js index 6c2188f..d8e3bfa 100644 --- a/packages/core/src/geometry/GeometrySystem.js +++ b/packages/core/src/geometry/GeometrySystem.js @@ -42,6 +42,11 @@ * @private */ this.cache = {}; + + /** + * A cache of currently bound buffer.. + */ + this.boundBuffers = {}; } /** @@ -197,7 +202,14 @@ const type = buffer.index ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER; const drawType = buffer.static ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW; - gl.bindBuffer(type, glBuffer.buffer); + if (this.boundBuffers[type] !== glBuffer) + { + this.boundBuffers[type] = glBuffer; + + gl.bindBuffer(type, glBuffer.buffer); + } + + this._boundBuffer = glBuffer; if (glBuffer.byteLength >= buffer.data.byteLength) { diff --git a/packages/core/src/textures/TextureSystem.js b/packages/core/src/textures/TextureSystem.js index b24926c..55c977c 100644 --- a/packages/core/src/textures/TextureSystem.js +++ b/packages/core/src/textures/TextureSystem.js @@ -111,7 +111,10 @@ const glTexture = texture._glTextures[this.CONTEXT_UID] || this.initTexture(texture); - gl.bindTexture(texture.target, glTexture.texture); + if (this.boundTextures[location] !== texture) + { + gl.bindTexture(texture.target, glTexture.texture); + } if (glTexture.dirtyId !== texture.dirtyId) {