Repository navigation
Conversation
Keep PIXI.WebGLRenderer.textureArray in sync with texture unit bindings, stop binding the batch's first texture on the active unit, and upload dirty or late-loaded textures before drawing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| gl.activeTexture(gl.TEXTURE0 + texture.textureIndex); | ||
|
|
||
| gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]); | ||
| PIXI.WebGLRenderer.textureArray[texture.textureIndex] = texture; |
Author
There was a problem hiding this comment.
Flushed the sprite batch before the eager TileSprite texture upload in 6cb50ea.
| } | ||
| } | ||
| else | ||
| else if (!PIXI._enableMultiTextureToggle) |
Author
There was a problem hiding this comment.
Restored the cached texture bindings after first-use multi-texture shader initialization in 6cb50ea.
Co-authored-by: samme <435681+samme@users.noreply.github.com>
| } | ||
| } | ||
| else | ||
| else if (!PIXI._enableMultiTextureToggle) |
… and RenderTexture resize - TileSprite: flush before uploading the tiling texture, and upload it on the unit the vertices sample. - PixiShader.initMultitexShader: restore existing unit bindings after the dummy-texture hack instead of clobbering them mid-render. - FilterTexture: restore the previous binding after creating or resizing. - Treat base textures without a GL texture as needing an upload. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| } | ||
| } | ||
| else | ||
| else if (!PIXI._enableMultiTextureToggle) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

In multi-texture (MT) mode the static
PIXI.WebGLRenderer.textureArraycache records which texture is bound to each texture unit. Several code paths rebound units without updating it, andWebGLSpriteBatch.renderBatchbound the first texture of a batch on whichever unit was active, so sprites drew with the wrong texture. Only one texture per batch was uploaded in MT mode, so late-loaded or changed canvas textures rendered blank or stale.Cache correctness
PIXI.WebGLRenderer.invalidateTextureUnit(unit?).updateTexture/updateCompressedTexturenow record the bound texture in the cache.renderBatchno longer binds the first texture on the active unit in MT mode (non-MT path unchanged).initContext,PixiShader(initMultitexShader,initSampler2D,syncUniforms),Rope,Creature,WebGLFilterManagerpush/pop,FilterTexture._CreateFramebuffer.Upload gap
WebGLSpriteBatch.render,renderTilingSprite(newbindMultiTexturehelper) andWebGLFastSpriteBatch.renderSprite/rendernow flush andupdateTexturedirty base textures; sprites whose texture isn't loaded yet are skipped.Filters
pushFilternow unbinds unit 0 after creating/resizing the filter texture. Previously the oldrenderBatchbind hid a feedback loop (filter target left bound while rendered to), which Chrome reported as GL errors once the bind was removed.Testing
Text, with temporary instrumentation (not committed) comparing the cache to actual GL bindings. Before: ~92k stale-unit hits in 2.5 s and mostly black sprites. After: 0 hits and everything renders. Non-MT mode renders correctly.eslint srcandnpm run build-testpass.Known, not addressed here
WEBGL_lose_contextdoesn't recover, before or after this change (shaders/buffers from the old context are reused;Cache.clearGLTexturesdoesn't mark textures dirty).Ropedoesn't setaTextureIndexfor the strip shader, so it can sample the wrong unit.