Page MenuHomePhabricator

Bug 1579235 - Part 9 - Optimize compositor surface overlays.
ClosedPublic

Authored by gw on Mar 2 2020, 12:45 AM.

Details

Summary

This patch improves the performance of compositor surfaces in
two ways:

(1) Ignore primitives behind the first compositor surface when

determining whether a tile needs to be moved to the overlay
(alpha) pass. This means WR only moves a tile to the alpha
pass when it has primitives that overlap with the compositor
surface bounding rect, and are ordered after that compositor
surface. In practice, this means most tiles are able to
remain in the fast (opaque) path. Typically, a small number
of tiles that contain overlay video controls are moved to the
alpha pass.

(2) Register the opaque compositor surfaces as potential occluders.

This allows tiles that are completely covered by a compositor
surface to be removed from the compositor visual tree, which
helps both the simple and native compositor modes.

Between them, these optimizations typically mean that when watching
video in full-screen, nothing is composited except the video surface
itself, and some small region(s) where video overlay controls are
currently active.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

gw created this revision.Mar 2 2020, 12:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2020, 12:45 AM
phab-bot requested review of this revision.Mar 2 2020, 12:46 AM
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: Restricted Project.
nical added inline comments.Mar 2 2020, 10:00 AM
gfx/wr/webrender/src/picture.rs
503

Please add a comment here that explains why we track z-ids separately for opaque and alpha tiles.

872

nit: "after to"

2346

nit: "eache"

2926

I suspect this wasn't meant to be in the final patch?

gw updated this revision to Diff 237245.Mar 2 2020, 8:31 PM
gw marked 3 inline comments as done.
gw added inline comments.Mar 2 2020, 9:03 PM
gfx/wr/webrender/src/picture.rs
2926

Indeed - just in for testing on try runs. Removed now!

Bert accepted this revision.Mar 2 2020, 9:27 PM
Bert added inline comments.
gfx/wr/webrender/src/picture.rs
501

Nitpicking, but..

What happens if there are multiple video surfaces with elements in between them?
Do I understand correctly that all elements after the first (furthest) video go into the "alpha" part?
Would we still think of those as "foreground"?

I'm also a bit weary that some of the code uses "opaque versus alpha" terminology and some uses "background versus foreground". For example background_color has nothing to do with this (AFAIK)?

This revision is now accepted and ready to land.Mar 2 2020, 9:27 PM
gw added inline comments.Mar 2 2020, 9:36 PM
gfx/wr/webrender/src/picture.rs
501

Yep, we would still consider them foreground.

The goal is that we get (near) optimal performance for the case when there is a single video affecting any tile. If more than one video affects a tile, we still get correctness, and good performance, but not necessarily optimal, since we consider the union of all compositor surface rects in determining whether we need to move the content tile to the alpha pass. This should cover the very common case well, while still being correct and reasonable in edge cases with multiple videos per tile.

I'll have a ponder on a way to tidy up some of that terminology.