New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce primitive clustering and use for some basic cases. #3238

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@gw3583
Collaborator

gw3583 commented Oct 29, 2018

Primitive clusters are used to group primitives within a picture
into similar categories during scene building.

Initially, these are only used to group primitives by spatial node
and by backface flags. In future, these will include spatial
clustering, which will allow removal of much of the per-primitive
bounding rect and culling code during frame building.

In this patch each primitive belongs to one cluster only, but
when spatial clusters are introduced, a primitive will belong
to one or more cluster(s). Clusters are processed during the
initial picture traversal, allowing the picture bounding rect to
be found without touching all primitives.

There's a couple of goals of this work:

  • Reduce the amount of comparison work we need to do to check
    if a cached picture surface is valid.
  • Allow cached picture surfaces to be drawn in tiles, to
    handle cases where only a small portion of a picture
    contents has changed.

There's also a number of other small related changes:

  • Store offscreen surface information outside the picture primitives.

    • Simplifies borrow check issues on picture traversal.
    • Eventually the surface structures will be retained between display lists, and hold cached surface details.
  • Build minimal local clip rect for primitives during scene building.

    • Used to allow quick calculation of picture bounding rects.
    • Can take advantage of this to reduce work during frame building (not done yet).
  • Picture bounding rect calculation is done during initial picture traversal pass.

    • Much faster than previously, as we only need to calculates bounds for each cluster.
  • Backface visibility is done once per cluster now, rather than per-primitive.

  • Intern the primitive local rect and clip rects for future use.


This change is Reviewable

Refactor chase tracing to work with primitive instance IDs.
In the process of interning primitives, the PrimitiveIndex
will become less useful, eventually being removed since a
primitive instance will contain just a reference to an interned
primitive template.

Having the chase ID based on the PrimitiveIndex is complicating
some of that refactoring, so this patch switches it to create
a unique ID per primitive instance, which is then used by the
chase tracing code. The primitive ID only exists when the
tracing code is compiled in.
@gw3583

This comment has been minimized.

Collaborator

gw3583 commented Oct 29, 2018

(This includes the commit from #3236).

Looks like there is one failure on try:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1d65d6b0005b662956871ca809ce97962081f982

I'll investigate that in the morning, but that should hopefully only be a minor fix needed.

@gw3583

This comment has been minimized.

Collaborator

gw3583 commented Oct 29, 2018

r? @kvark

@nical

This comment has been minimized.

Collaborator

nical commented Oct 29, 2018

In future, these will include spatial
clustering, which will allow removal of much of the per-primitive
bounding rect and culling code during frame building.

Exciting!

Introduce primitive clustering and use for some basic cases.
Primitive clusters are used to group primitives within a picture
into similar categories during scene building.

Initially, these are only used to group primitives by spatial node
and by backface flags. In future, these will include spatial
clustering, which will allow removal of much of the per-primitive
bounding rect and culling code during frame building.

In this patch each primitive belongs to one cluster only, but
when spatial clusters are introduced, a primitive will belong
to one or more cluster(s). Clusters are processed during the
initial picture traversal, allowing the picture bounding rect to
be found without touching all primitives.

There's a couple of goals of this work:
- Reduce the amount of comparison work we need to do to check
  if a cached picture surface is valid.
- Allow cached picture surfaces to be drawn in tiles, to
  handle cases where only a small portion of a picture
  contents has changed.

There's also a number of other small related changes:
- Store offscreen surface information outside the picture primitives.
  - Simplifies borrow check issues on picture traversal.
  - Eventually the surface structures will be retained between display lists, and hold cached surface details.

- Build minimal local clip rect for primitives during scene building.
  - Used to allow quick calculation of picture bounding rects.
  - Can take advantage of this to reduce work during frame building (not done yet).

- Picture bounding rect calculation is done during initial picture traversal pass.
  - Much faster than previously, as we only need to calculates bounds for each cluster.

 - Backface visibility is done once per cluster now, rather than per-primitive.
 - Intern the primitive local rect and clip rects for future use.
@gw3583

This comment has been minimized.

Collaborator

gw3583 commented Oct 29, 2018

I realized that some of the existing picture logic relies on the calculated picture rect being the unclipped size. So I updated the patch to not include the local clip rect in the culling rect, for now. This doesn't have any impact on performance, since it matches previous behavior. As a follow up, we can fix this logic and start to take advantage of building the local clip rect during scene building.

The try run with this fix still has a few jobs to run, but looks good so far, so this is ready for review now.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=00db2fce1b954143a03d0d9b687bbf140d752563&selectedJob=208488140

@emilio

This comment has been minimized.

Member

emilio commented Oct 30, 2018

The OSX R2 crashes look related to webrender:

17:53:39     INFO -  3  XUL!mozilla::layers::APZSampler::~APZSampler() [Mutex.h:00db2fce1b954143a03d0d9b687bbf140d752563 : 60 + 0x5]

called by:

17:53:39     INFO -  7  XUL!webrender::render_backend::RenderBackend::update_document [render_backend.rs:00db2fce1b954143a03d0d9b687bbf140d752563 : 1039 + 0x1a]

May not be related to this PR though.

@staktrace

This comment has been minimized.

Contributor

staktrace commented Oct 30, 2018

APZSampler::~APZSampler crashes might be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1502495 - I've starred the failure as such.

@kvark

This comment has been minimized.

Member

kvark commented Oct 30, 2018

Reviewed as a part of #3244. I think we can close this one.

@gw3583

This comment has been minimized.

Collaborator

gw3583 commented Oct 30, 2018

Closing since this is reviewed as part of #3244.

@gw3583 gw3583 closed this Oct 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment