Closed Bug 1702228 Opened 3 years ago Closed 3 years ago

Cache linear gradients by default

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Blocks 1 open bug, Regressed 4 open bugs)

Details

Attachments

(3 files, 3 obsolete files)

... except with SWGL, for which the gradient brush shader is faster than samping from the texture cache.

This is a followup from bug 1687977 which did the work for conic and radial gradients. Linear gradients are a bit trickier because they are used a lot more, so greater care must be taken in ensuring that we don't introduce regressions in some cases.

There are also more fast paths to take into account.

See Also: → 1687977

Depends on D110403

I've put the work-in-progress changes here, while I look into some higher priority things. Hopefully I'll get back to it. The remaining work is:

  • make sure swgl still uses the non-cached linear gradient brush
  • carefully look at the performance and make sure we don't regress important cases (since the fast paths change)
  • adjust reftest references
Severity: -- → S4

This patch breaks linear gradients into two primitives:

  • LinearGradient is always rendered via the brush shader. It is only used with SWGL.
  • CachedLinearGradient is always rendered via a cached render task and the brush image shader. Its implementation is very similar to conic and radial gradients, with the addition of a fast-path for axis aligned gradients with two stops.

In addition the following changes are made:

  • The gradient fast path is simpler (only deals with two gradient stops).
  • Decomposing axis-aligned gradients into parts eligible for the fast path happens during scene building instead of frame building.

Instead of rendering 1xN pixels for cached gradient segments, just render the color of the gradient stops in 1x2 render tasks. This requires adjusting the texture coordinates in the image brush shader which looks a bit hacky, however it has a few advantages:

  • gradients occupy much less space in the texture cache because they are much smaller
  • gradients that use the same colors are more likely to reuse the same render tasks even if rendered at different sizes, which further reduces the occupied space.
  • the amount of rendered and sampled pixels is reduced as well.

Depends on D112018

Assignee: nobody → nical.bugzilla
Status: NEW → ASSIGNED
Attachment #9215739 - Attachment description: WIP: Bug 1702228 - Cache linear gradients by default. → WIP: Bug 1702228 - Cache linear gradients by default

Depends on D112018

Depends on D112969

Attachment #9215739 - Attachment description: WIP: Bug 1702228 - Cache linear gradients by default → Bug 1702228 - Cache linear gradients by default. r=gw
Attachment #9217419 - Attachment description: WIP: Bug 1702228 - Check gradient parameters. → Bug 1702228 - Check gradient parameters. r=gw
Attachment #9217420 - Attachment description: WIP: Bug 1702228 - Adjust reftests. → Bug 1702228 - Adjust reftests. r=gw
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch

This bug seems to have regressed in Thunderbird. Back-out fixes the issue.

We use linear-gradient(to left, transparent, transparent 3px, var(--in-content-categories-background) 3px) which is no more shown. to right or 90deg works. I also tried -90deg which also didn't work but -89deg or -91deg are working.

Flags: needinfo?(nical.bugzilla)

FYI, this bug caused a regression on the discord homepage (https://discord.com) as per this regression range.

Minimal test case: https://jsfiddle.net/g4sL2e5c/show

Regressions: 1707460

(In reply to LE from comment #11)
Thanks for the test-case! I filed bug 1707460 for it. Even if we revert this change, we should probably add that as an automated test somehow.

Regressions: 1707521
Attachment #9212805 - Attachment is obsolete: true
Regressions: 1707930
Flags: needinfo?(nical.bugzilla)
Regressions: 1707744
Regressions: 1708540
Regressions: 1708959
Regressions: 1709435
Attachment #9212806 - Attachment is obsolete: true
Regressions: 1715370
Regressions: 1726388
Regressions: 1767182
Regressions: 1833123
Regressions: 1833397
Attachment #9215740 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: