Closed Bug 1621390 Opened 5 years ago Closed 5 years ago

Tile backdrop/clear optimizations for (Software) WebRender

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: lsalzman, Assigned: gw)

References

(Blocks 2 open bugs)

Details

(Keywords: perf)

Attachments

(1 file)

For SW-WR, the costs of clearing both the Z-buffer and color buffer can be substantial, whereas with HW accel these costs are usually more negligible

To this end, WebRender also identifies a backdrop per picture cache tile. In the general case, if we can avoid drawing this backdrop using a shader and can instead replace the draw with glClear calls, there can be significant improvements in performance so no shader is needed and we avoid churning the Z-buffer.

The optimization might work as follows:
For solid color backdrops - just replace the solid color draw with a clear using the color and z-id of the primitive. If we either know nothing draws behind the backdrop or can at least avoid anything drawing behind it, then we don't even need to know the z-id at all, and can instead just clear the z-buffer to the normal initial clear z-id since the backdrop will remain behind all drawn primitives in any case.

For complicated backdrops (images/gradients/etc.) - Skip clearing the color buffer entirely but still at least use glInvalidateFramebuffer to signal to HW OpenGL implementations that we are not reusing the previous frame's color buffer. Then clear the z-buffer to the appropriate z-id of the primitive (like above, this can just be the clear z-id if we know nothing is behind it). Then later during normal drawing draw the primitive, potentially disabling depth writes/mask if that would be viable without complicating the batching code (otherwise, it isn't terribly necessary to disable depth mask, but would be a slight benefit).

For composite backdrops where several primitives cover the entire tile but no single primitive covers the entire tile - Here we can again just skip clearing the color buffer, but still use glInvalidateFramebuffer. Clear the z-buffer as normal. This would still benefit in that we can avoid color buffer churn in SWGL for pixels that are just going to be overridden by primitives anyway.

Assignee: nobody → gwatson

There's a couple try failures to sort out tomorrow (I know what is causing them), but this should cover the optimization for backdrop colors.

I think we will just do the backdrop color optimization for now, the other types are very rare and probably not worth the complexity - but we could revisit that if we see them in profiles.

Pushed by gwatson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6199f7b91e8b Optimize backdrop primitives by collapsing to clear color. r=lsalzman,Bert
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
See Also: → 1598972
Regressions: 1665815
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: