Closed Bug 1669840 (sw-wr-perf-opacity) Opened 4 years ago Closed 3 years ago

Improve opacity flattening

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox87 --- wontfix
firefox88 --- wontfix
firefox89 --- wontfix
firefox90 --- fixed

People

(Reporter: jrmuizel, Assigned: bradwerth)

References

(Blocks 2 open bugs)

Details

(Keywords: perf-alert)

Attachments

(4 files, 1 obsolete file)

Currently it seems like WebRender will draw things into a temporary even if the opacity could be flattened directly into a single item. Examples of this are images or gradients.

In the non-WebRender case we go to some effort to flatten these to avoid the the cost of the temporary. Not doing this flattening shows up especially with sw-wr.

Blocks: 1669520

I double checked and it looks like the existing opacity flattening that we have is already being performed at the gecko display list level and doesn't apply to gradient backgrounds. Is this true Miko?

Flags: needinfo?(mikokm)

It looks like Chrome will fold opacity into most single display items:
https://source.chromium.org/chromium/chromium/src/+/master:cc/paint/paint_op_buffer.cc;l=2698;drc=7a942548e0af7397f79bf07b4ca03ade10d04019;bpv=0;bpt=1
So I'd expect them to fold it into the drawImage with a gradient.

(In reply to Jeff Muizelaar [:jrmuizel] from comment #1)

I double checked and it looks like the existing opacity flattening that we have is already being performed at the gecko display list level and doesn't apply to gradient backgrounds. Is this true Miko?

This is correct. I wrote a quick patch to enable this for nsDisplayBackgroundImage items, can you try if it helps with bug 1669520?

Flags: needinfo?(mikokm)

It looks like this should fix the problem I was seeing but it also looks like this will break opacity on regular images because nsImageRenderer::BuildWebRenderDisplayItems seems to only use its aOpacity parameter for gradients.

Severity: -- → S3
Priority: -- → P3
Flags: needinfo?(mikokm)
Blocks: sw-wr-perf
Blocks: 1678265
No longer blocks: 1678265
See Also: → 1678265
Alias: sw-wr-perf-opacity
Blocks: 1678779
Assignee: nobody → bwerth
Status: NEW → ASSIGNED
Flags: needinfo?(mikokm)
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/555f8ed5cc85
Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/55707a03f41d
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel

Depends on D103130

Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/396931075ff1
Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/d54787a62ba0
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/7ceccf133786
Part 3: Update test expectations. r=jrmuizel
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1582820076e0
Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/b4f43fdd6d04
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/c648cec12f77
Part 3: Update test expectations. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch

(In reply to Pulsebot from comment #16)

Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1582820076e0
Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/b4f43fdd6d04
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha
with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/c648cec12f77
Part 3: Update test expectations. r=jrmuizel

== Change summary for alert #28670 (as of Mon, 08 Feb 2021 10:31:22 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
25% rasterflood_gradient linux64-shippable e10s stylo 1,092.92 -> 1,365.75
25% rasterflood_gradient linux64-shippable e10s stylo 1,093.75 -> 1,366.00
16% rasterflood_gradient macosx1014-64-shippable-qr e10s stylo webrender-sw 363.46 -> 420.58
8% rasterflood_gradient linux64-shippable-qr e10s stylo webrender-sw 458.00 -> 492.67
5% rasterflood_gradient windows10-64-shippable-qr e10s stylo webrender-sw 437.46 -> 459.58

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=28670

Flags: needinfo?(bwerth)
Blocks: 1692070
Regressions: 1696761

Per discussion with Brad, we're backing this out from m-c as well while he works on finding a solution to bug 1696761.
https://hg.mozilla.org/integration/autoland/rev/f2aa3c52790966347d5206922245ea968bc428e3

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 87 Branch → ---
Regressions: 1699884

(In reply to Ryan VanderMeulen [:RyanVM] from comment #20)

Per discussion with Brad, we're backing this out from m-c as well while he works on finding a solution to bug 1696761.
https://hg.mozilla.org/integration/autoland/rev/f2aa3c52790966347d5206922245ea968bc428e3

== Change summary for alert #29390 (as of Tue, 23 Mar 2021 05:13:18 GMT) ==

Regressions:

Ratio Suite Test Platform Options Absolute values (old vs new)
67% rasterflood_gradient windows10-64-shippable-qr e10s stylo webrender-sw 1,196.92 -> 389.08
65% rasterflood_gradient windows10-64-shippable-qr e10s stylo webrender-sw 1,299.92 -> 458.33
19% rasterflood_gradient linux1804-64-shippable e10s stylo 745.08 -> 602.67
7% rasterflood_gradient windows10-64-shippable e10s stylo 1,329.08 -> 1,239.75

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=29390

Comment on attachment 9180427 [details]
Bug 1669840 Part 1 - Allow applying opacity to nsDisplayBackgroundImage items

Revision D92941 was moved to bug 1696761. Setting attachment 9180427 [details] to obsolete.

Attachment #9180427 - Attachment is obsolete: true

Comment on attachment 9199424 [details]
Bug 1669840 Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity.

Revision D103130 was moved to bug 1696761. Setting attachment 9199424 [details] to obsolete.

Attachment #9199424 - Attachment is obsolete: true

Comment on attachment 9200948 [details]
Bug 1669840 Part 4: Update test expectations.

Revision D103938 was moved to bug 1696761. Setting attachment 9200948 [details] to obsolete.

Attachment #9200948 - Attachment is obsolete: true

Update on what it will take to land these patches again. The regression tracked in Bug 1696761 is the reason why these patches can't be re-landed. The testcase attachment 9208516 [details] there is useful. Loading that testcase, you'll see a black background (on macOS) or a transparent black background (on Linux) when you should see an opaque 0.1 gray background. This is happening because the compositor is providing an uninitialized surface as a background and blending a 0.1 alpha black GIF against it. On macOS the compositor gives a default fill of 1.0 alpha black. On Linux, the compositor gives a fill of 0.0 alpha.

I haven't been able to track down where those surfaces are created or handed off without first being cleared to the 1.0 alpha white color, as they should be.

Attachment #9180427 - Attachment description: Bug 1669840 - Allow applying opacity to nsDisplayBackgroundImage items → Bug 1669840 Part 1 - Allow applying opacity to nsDisplayBackgroundImage items
Attachment #9180427 - Attachment is obsolete: false
Attachment #9199424 - Attachment is obsolete: false
Attachment #9200948 - Attachment is obsolete: false
Attachment #9221623 - Attachment description: Bug 1669840 Part 4: Include image instance color alpha in check for opaque backdrop. → Bug 1669840 Part 3: Include image instance color alpha in check for opaque backdrop.
Attachment #9221645 - Attachment description: Bug 1669840 Part 5: Add a reftest to check blending of animated GIFs. → Bug 1669840 Part 4: Add a reftest to check blending of animated GIFs.
Attachment #9200948 - Attachment description: Bug 1669840 Part 3: Update test expectations. → Bug 1669840 Part 5: Update test expectations.
Attachment #9221645 - Attachment is obsolete: true
Attachment #9200948 - Attachment description: Bug 1669840 Part 5: Update test expectations. → Bug 1669840 Part 4: Update test expectations.
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8444d88d1869
Part 1 - Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/7716542373a3
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/31dfd306b953
Part 3: Include image instance color alpha in check for opaque backdrop. r=gfx-reviewers,lsalzman
https://hg.mozilla.org/integration/autoland/rev/be66ef46592b
Part 4: Update test expectations. r=jrmuizel
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a4d21aa2f97d
Part 1 - Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/17d1706271a9
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/dc8740f5d193
Part 3: Include image instance color alpha in check for opaque backdrop. r=gfx-reviewers,lsalzman
https://hg.mozilla.org/integration/autoland/rev/b0dc93c36fb5
Part 4: Update test expectations. r=jrmuizel
Blocks: 1700613
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/04e81660c75f
Part 1 - Allow applying opacity to nsDisplayBackgroundImage items r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/ab9ae661da2c
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/73d45273bf7f
Part 3: Include image instance color alpha in check for opaque backdrop. r=gfx-reviewers,lsalzman
https://hg.mozilla.org/integration/autoland/rev/9a3c2b7dfe84
Part 4: Update test expectations. r=jrmuizel

Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.

Flags: needinfo?(bwerth)

perf key word?

(In reply to Worcester12345 from comment #38)

perf key word?

This optimization is not protected behind a preference.

(In reply to Pulsebot from comment #35)

Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/04e81660c75f
Part 1 - Allow applying opacity to nsDisplayBackgroundImage items
r=jrmuizel,mstange
https://hg.mozilla.org/integration/autoland/rev/ab9ae661da2c
Part 2: Make nsImageRenderer::BuildWebRenderDisplayItems premultiply alpha
with provided opacity. r=miko,jrmuizel
https://hg.mozilla.org/integration/autoland/rev/73d45273bf7f
Part 3: Include image instance color alpha in check for opaque backdrop.
r=gfx-reviewers,lsalzman
https://hg.mozilla.org/integration/autoland/rev/9a3c2b7dfe84
Part 4: Update test expectations. r=jrmuizel

== Change summary for alert #30198 (as of Tue, 25 May 2021 09:39:06 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
21% rasterflood_gradient (docs) linux1804-64-shippable e10s stylo 628.83 -> 759.17
20% rasterflood_gradient (docs) windows10-64-shippable-qr e10s stylo webrender-sw 1,114.33 -> 1,334.17
19% rasterflood_gradient (docs) linux1804-64-shippable-qr e10s stylo webrender-sw 1,117.88 -> 1,335.50
15% rasterflood_gradient (docs) macosx1015-64-shippable-qr e10s stylo webrender-sw 975.25 -> 1,125.25
6% rasterflood_gradient (docs) windows10-64-shippable e10s stylo 1,253.96 -> 1,332.75

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=30198

Regressions: 1723469
Regressions: 1748375
Regressions: 1752807
See Also: → 1765218
Regressions: 1768058
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: