Closed Bug 1650984 Opened 3 months ago Closed 2 months ago

Allow SWGL render compositor to work asynchronously during picture cache tile updates

Categories

(Core :: Graphics: WebRender, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: lsalzman, Assigned: lsalzman)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(3 files)

Now that we have do SWGL compositing entirely in software for some platforms, it can show up as a substantial portion of profiles during scrolling, around 25% which was mostly not present with the older OpenGL compositing path. We can pipeline some of this overhead between compositing and updating of picture cache tiles, since many picture cache tiles that are still cached from previous frames have no dependencies on the ones currently being updated or must be composited before the updating one anyway (such as a background).

In the best case scenario, this allows compositing overhead to almost entirely be hidden, so long as there is another core around that is not busy. As updating picture cache tiles tends to take much more time than compositing, this gives plenty of time to composite asynchronously in the background.

Initial testing on a few sites with a prototype shows this can drop about 20% or more off the profile again, bringing us pretty close to the performance of the older OpenGL compositing.

This restructures the WR Compositor interface a bit to support compositing
earlier in the frame. An invalidate_tile hook is added that gets called
first to signal that some picture cache tiles will be modified later in the
frame. The renderer then calls add_surface earlier before the picture cache
tiles are updated, so that any tiles that aren't invalid can proceed to
composite early before that. Finally, bind/unbind get called after so that
it can work potentially work in parallel with any tiles that are already
compositing early.

This spawns a new SwComposite thread inside SwCompositor. Tile composite jobs
are submitted over a channel to the thread, with a condition being signaled
after all jobs are processed. The SwCompositor computes a dependency order for
the tiles based on whether it overlaps a tile that has been invalidated and
needs to be updated during the current frame. As tiles are gradually updated,
all tiles that would depend on the update as denoted by the dependency order get
submitted so that composition can proceed. Ultimately, this allows tile updates
and compositing to work in parallel, pipelining much of the cost of compositing.

Depends on D82473

SwCompositor needs to send SWGL textures references safely to the SwComposite
thread. However, the SWGL context's texture store may grow and make accessing
these tables unsafe. To work around this, this patch adds a LockedResource
API that locks down access to these textures ahead of time both to ensure that
no table access is necessary and to help detect any unexpected modifications
of these textures while they are locked. These LockedResource objects can then
be composited safely in another thread without interfering with normal SWGL
operation in the original that that isn't simultaneously using these textures.

Depends on D82474

Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fceb25f6286b
add invalidate_tile to WR Compositor interface. r=gw
https://hg.mozilla.org/integration/autoland/rev/b013dfd51ff6
make SwCompositor composite asynchronously in another thread. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/97f04a5dac7c
add SWGL LockedResource API. r=jimb,jrmuizel
Pushed by ncsoregi@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0823783b08d6
Fix trailing space. r=fix CLOSED TREE
Regressions: 1653374
Regressions: 1653413
Regressions: 1653426
Regressions: 1653424
Regressions: 1653420
Regressions: 1653395
Regressions: 1653493
Regressions: 1653503
Regressions: 1654123
You need to log in before you can comment on or make changes to this bug.