Skip to content

Fix multitexture sprite batch rebinding unit 0 to the batch's first texture - #770

Draft
samme with Copilot wants to merge 3 commits into
masterfrom
copilot/investigate-issue-231
Draft

samme with Copilot wants to merge 3 commits into
masterfrom
copilot/investigate-issue-231

Conversation

Copilot AI commented Nov 14, 2026

Copy link
Copy Markdown

With multitexture batching and renderer.setTexturePriority(), a canvas-wide quad rendered as one of the prioritised textures. This is the "sprite stretches to fill the canvas" symptom. It happens with the default game.debug overlay, which sits on texture unit 0.

new Phaser.Game({ renderer: Phaser.WEBGL, multiTexture: true, state: { create: function ()
{
    game.renderer.setTexturePriority([ 'a', 'b', 'c' ]);
    game.add.sprite(10, 10, 'a');   // debug overlay now draws as 'a' across the whole canvas
} } });
  • Cause: WebGLSpriteBatch#renderBatch always ran gl.bindTexture() for the batch's first base texture. In multitexture mode render() has already bound each sprite's texture to its own unit, so this bind landed on whatever unit was active, usually unit 0. That replaced the debug canvas texture while PIXI.WebGLRenderer.textureArray[0] still reported it as bound, so it was never rebound.
  • Fix: renderBatch now only does that bind when multitexture is disabled. The dirty-texture upload path is unchanged.
  • Changelog: added an entry for the fix.

This is a follow-up to the earlier multitexture binding fixes (#761, #768), which did not cover this path.

Verified only on software WebGL in headless Chromium, with pixel readback of the debug overlay, three solid-colour sprites and the background. Canvas mode, TileSprite, Rope and Creature were not exercised.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…exture

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants