Skip to content

Skip rasterizing dirty tiles outside the viewport - #1606

Merged
shlzxjp merged 3 commits into
mainfrom
feature/partyhuang_tile_dirty
Oct 29, 2026
Merged

shlzxjp merged 3 commits into
mainfrom
feature/partyhuang_tile_dirty

Conversation

@Hparty

@Hparty Hparty commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

What

In RenderMode::Tiled, dirty regions were mapped to the current zoom-space cache without any viewport clipping, so a dirty region extending beyond the viewport re-rasterized cached off-screen tiles (including their background captures). The partial path already clips with &surfaceRect; the tiled path did not.

DisplayList::invalidateCurrentTileCache() now compares the tiles it reaches against the viewport:

  • a tile with no overlap with the viewport is invalidated instead of redrawn;
  • tiles overlapping the viewport keep the existing "redraw only the dirty portion" behaviour, using the unclipped dirty rect so a tile straddling the viewport edge does not keep stale pixels in the part outside the viewport;
  • the batched single-draw-call path is used only when the dirty rect lies fully inside the viewport, otherwise it would rasterize the off-screen part of the dirty rect.

Invalidated tiles are rasterized again by collectScreenTasks() once the viewport reaches them. Note that this re-rasterization goes through the missing-tile path, so in TileUpdateMode::Smooth/Fast those tiles are subject to the per-frame budget and may briefly show fallback content, where previously they were already valid because they had been redrawn off-screen.

Test plan

  • New LayerTest.TiledDirtyRegionOutsideViewport: pans a tiled display list, changes a layer whose bounds cover both sides of the viewport, then checks (a) the off-screen part of a tile straddling the viewport edge and (b) a tile that was fully off-screen, both after panning back. Removing either the invalidation or the unclipped draw rect makes the corresponding assertion fail with stale pixels.
  • Full OpenGL suite A/B against an unmodified build of the same tree: 596 rendered images byte-identical, i.e. no visual change.
  • Full SwiftShader suite (676 tests) passes locally.

Note

The tile seam pixel itself is not asserted: on the SwiftShader backends the pixel exactly on the boundary between a live tile and an invalidated one keeps ~2/255 of the previous colour (measured: only that single pixel of the row differs, and it follows the old colour, e.g. fffd0200 when the old colour was green). Every native backend reproduces the pixel exactly. It is a sub-texel sampling leak from the stale atlas cell that the invalidated tile keeps; clearing the cell on invalidation would remove it at the cost of a tile-sized fill, so it is left for a follow-up. The test probes 4px inside the sliver to stay off that seam.

shlzxjp
shlzxjp previously approved these changes Oct 29, 2026
@shlzxjp
shlzxjp merged commit a57ea97 into main Oct 29, 2026
15 checks passed
@shlzxjp
shlzxjp deleted the feature/partyhuang_tile_dirty branch October 29, 2026 08:26
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