fix(webgl): stale GPU quads on rtt toggle and generic reorder (surgical guard) - #871
Closed
wouterlucas wants to merge 2 commits into
Closed
fix(webgl): stale GPU quads on rtt toggle and generic reorder (surgical guard)#871wouterlucas wants to merge 2 commits into
wouterlucas wants to merge 2 commits into
Conversation
…al guard) rtt toggle changed which buffer (main vs rttQuadBuffer) a node writes to without rebuilding the flat render list, so the surgical bufferSubData path left stale quads on the GPU (blue/white flash, PR #861). - CoreNode.set rtt now calls stage.requestRenderListUpdate() -> WebGlRenderer.invalidateQuadBuffer() so the next frame does a FULL bufferData with re-assigned contiguous slots. - WebGlRenderer.addQuad() adds a generic guard: if quadBufferIndex != -1 && quadBufferIndex != curBufferIdx && !isQuadDirty force isQuadDirty=true (no !isRTT gate, just index vs index). This heals any reorder that bypassed invalidation via surgical re-upload. - Add minimal repro examples/tests/dirty-stale-slot.ts (3 rects, green->light-green->orange) and unit test rtt toggle -> FULL. Fixes the reported 'all blue images' on dirty repaints. Refs: #861
Captured via docker (RUNTIME_ENV=ci) for the 4 automation steps: initial, correct-reorder-full, surgical-color, recover. Outer rects stay red/blue across all frames (no stale quads); the middle rect cycles green -> light-green -> orange -> green.
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.
Fixes the reported “all blue images” on dirty repaints (PR #861 surgical path).
Root cause
CoreNode.set rtt()changed which buffer (quadBuffervsrttQuadBufferinWebGlRenderer.addQuad()) a node writes to without rebuilding the flat render list. Next frame choseSURGICAL(dirty/len < 0.4) and onlybufferSubData’d dirty quads — outer quads stayed stale on the GPU (blue0x0000ffff/ white placeholder).Stage.requestRenderListUpdate()→WebGlRenderer.invalidateQuadBuffer()(directstage.renderListNodessplice).Fix
src/core/CoreNode.ts:2727set rttnow callsstage.requestRenderListUpdate()→invalidateQuadBuffer()(quadBufferIndex=-1, needsFull=true) so the next frame does a singlebufferDatawith re-assigned contiguous0,20,40…slots. Mirrorsclipping/clipRadius/zIndex.src/core/renderers/webgl/WebGlRenderer.ts:505addQuad()generic guard:quadBufferIndex != -1 && quadBufferIndex != curBufferIdx && !isQuadDirty → isQuadDirty=true(no!isRTTgate, just index vs index). Heals any bypass via surgical re-upload; 2/3 dirty then falls back toFULLvia0.4threshold.Test
src/core/renderers/webgl/WebGlRenderer.dirtyQuadBuffer.test.ts:507—rtt toggle invalidates → FULL(fakedstage.txManager+gpuBuffermirror).examples/tests/dirty-stale-slot.ts— minimal480×160aredbgreencblue,bgreen→light-green→orange→green(4 snapshotsinitial/correct-reorder-full/surgical-color/recover).Refs: #861