Closed Bug 1678119 (sw-wr-perf-alpha) Opened 4 years ago Closed 3 years ago

Avoid doing clip/aa work in ALPHA_PASS shaders if we know we don't need it in VS

Categories

(Core :: Graphics: WebRender, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: jrmuizel, Assigned: lsalzman)

References

(Blocks 1 open bug)

Details

(Keywords: perf-alert)

Attachments

(4 files)

No description provided.
Blocks: sw-wr-perf
Severity: -- → S3
Alias: sw-wr-perf-alpha
Depends on: sw-wr-perf-do-clip

init_transform_fs() is the remaining alpha-pass shader bottleneck since bug 1688104 sped up clip-masking. Most of the brush shaders have fast-paths now that gate the inner loops with a call to has_valid_transform_bounds(), so that at least in the axis-aligned case, we avoid calling init_transform_fs() for every pixel. However, in cases where things are not axis-aligned, we could do better here finding some way to constrain the init_transform_fs() overhead to only those pixels bounding each span that actually need it, while skipping it entirely for inside/opaque pixels.

Blocks: 1685943
Depends on: 1691139

The main goal of this patch is to move all the complexity of optionally
handling anti-aliasing out of the GLSL drawSpan fast-paths and into SWGL
itself into specific blend-mode handling of anti-aliasing. Mainly this
adds a swgl_antiAlias() extension to be called from the GLSL vertex shader,
after which no further involvement is necessary from the shader to work.
This also enables SWGL to better track those areas of a span that don't
need any anti-aliasing applied, and so can potentially be faster.

Some massaging of blend_pixels() was necessary to get it to inline properly
with all the extra cases added. This is mainly a consequence of the DO_AA
macro that lives inside BLEND_CASE, which is used to handle the dispatching
of new AA_BLEND_KEY and AA_MASK_BLEND_KEY cases. The parameters for these
AA modes are mostly handled in SWGL via the aa_span() function, which computes
the area of the span where non-opaque AA weights are necessary and where it can
skip over the opaque interior.

There are some incidental drive-by cleanups that were necessary of bvecs and
pack_pixels.

Assignee: nobody → lsalzman
Status: NEW → ASSIGNED

This cleans up the WR brush shaders to not have to use its own
implementation of init_transform_fs() for anti-aliasing when SWGL
is available. To enable this, most of the details of AAing have
been moved into brush.glsl to simplify the control knobs and
allow easier modifications.

With swgl_antiAlias() used, the drawSpan fast-paths no longer have to
care about whether ot not AA is enabled, so we can more easily stay
on these fast-paths without worry.

Depends on D104492

Now that most of the complicated alpha-pass features such as clip-masking and anti-aliasing
are handled in SWGL during the blend stage, most of the fast-paths are identical and only call
swgl_commitTextureLinear in a tight loop. We can do a lot better here by just moving that loop
into SWGL, not only making it faster but removing all the redundant boiler-plate code out of
the shaders.

Depends on D104494

Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b9dce9d33351
Implement native anti-aliasing in SWGL. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/16b232a35692
Use swgl_antiAlias() in WR brush shaders. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/163ea6e7bcc2
Update reftest fuzz for SWGL anti-aliasing. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/c93691df2440
Simplify SWGL image fast-paths since complex blending is no longer required. r=jrmuizel
Flags: needinfo?(lsalzman)
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/97bbb1c5a386
Implement native anti-aliasing in SWGL. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/2c477ec6ac24
Use swgl_antiAlias() in WR brush shaders. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/545e2c8b42ba
Update reftest fuzz for SWGL anti-aliasing. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/1602ec8392d6
Simplify SWGL image fast-paths since complex blending is no longer required. r=jrmuizel

== Change summary for alert #28785 (as of Sat, 13 Feb 2021 07:05:08 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
2% rasterflood_svg linux64-shippable-qr e10s stylo webrender-sw 9,549.73 -> 9,320.79

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

Regressions: 1700520
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: