Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upVarious improvements towards correct handling of 3d transforms. #2995
Conversation
|
r? @kvark This is, I hope, the last major change we need in order to be able to rasterize pictures in different coordinate spaces. This will make caching feasible for all picture surface types, and make it possible to fix the remaining 3d transform issues. Apologies for the size of the patch! Try run is: There's a lot of orange items, some discussion below: Unrelated intermittents: FAIL -> PASS PASS -> FAIL Most of the new failures are fine to fuzz, I think. I'm still not 100% sure what is causing the
As you can see from above, the incoming offset in spatial node 6 is different between the tests - one has an offset while one doesn't. I think this explains why the test fails, and suggests the problem lies earlier than the changes in this patch could cause. But I want to do a bit more investigation first to try and confirm what is going on here. |
|
(TL;DR of the above is: apart from review comments / changes, I need to do a little bit more investigation of a couple of the try results, to either confirm that they are unrelated to this patch, or fix them first before landing). |
|
OK, I think I have fixed the |
wasn't a Gecko issue after all? what was it then? |
|
It was an issue with not including the accumulated scroll offset when defining a new coordinate system. Current try run is here: Still a few jobs to go, but I think it looks good now, despite all the orange items (I'll follow up with some details in a comment shortly about the differences). |
|
Linux: [1] [2] [mda1] [h1] [h2] [tp6] [mda2] [wpt3] unrelated failures [R1] New PASS in mask-layer-3.html OSX: [R1] New PASS in 1081185-1.html Windows: Discussion: So the failures are in img-novb-height-meet-1.html, img-novb-height-slice-1.html and long-chain.html (on Linux). In each of these cases the results are very close, and already have fuzziness on WR and/or other backends. With signoff from @jrmuizel, I think these are fine to fuzz, which just leaves new PASS results. |
|
I find this to be an amazing set of changes. It simplifies a bunch of code (like content origin offsetting, some conversions to device space), and at the same time makes our type system stronger by introducing the picture coordinate space. Got a few notes below:
webrender/src/clip.rs, line 327 at r1 (raw file):
not clear (from reading this only) why the struct has 2 clip rects and what is the difference for the user webrender/src/clip.rs, line 418 at r1 (raw file):
I wonder how you resisted the temptation to call it webrender/src/clip.rs, line 484 at r1 (raw file):
so this is a possible performance regression? webrender/src/frame_builder.rs, line 75 at r1 (raw file):
is webrender/src/frame_builder.rs, line 105 at r1 (raw file):
nit: this particular field doesn't seems like it should be a part of PictureState, given that it's not going to change upon traversing the items of the picture. Is there a more appropriate home for it to live? webrender/src/picture.rs, line 282 at r1 (raw file):
could we avoid going through untyped, e.g. by scaling with webrender/src/picture.rs, line 499 at r1 (raw file):
is it ever needed as non-i32? webrender/src/prim_store.rs, line 170 at r1 (raw file):
similarly, would be great to avoid going through "untyped" webrender/src/prim_store.rs, line 527 at r1 (raw file):
IIRC, we wanted to rename this one? webrender/src/prim_store.rs, line 1737 at r1 (raw file):
the pattern of those two matches is repeated in other places, we should make a helper with a descriptive name webrender/src/prim_store.rs, line 2266 at r1 (raw file):
please document what the return value means here webrender/src/prim_store.rs, line 2744 at r1 (raw file):
so if there wasn't anything in the previous frame means we aren't going to update anything this frame? Wouldn't this cause us to miss some clips that activate only upon scrolling and such? webrender/src/util.rs, line 465 at r1 (raw file):
hmm, so this is no longer taking the screen bounds into account, which means produced polygons will be guaranteed to stretch to infinity if they intersect the near plane. Feeding that data to GPU then could cause us severe precision issues, and I'd prefer us to not torture it too much :) |
|
I'm fine with bumping the fuzz on those tests. |
webrender/src/clip.rs, line 327 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Added comments describing each clip rect. webrender/src/clip.rs, line 418 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/clip.rs, line 484 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
In theory, yes - although I haven't observed it anywhere on real pages. It should be easy enough to fix if/when we come across a test case where it would help. webrender/src/frame_builder.rs, line 75 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
It is not - well spotted :) Removed it from the context struct altogether. webrender/src/frame_builder.rs, line 105 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Ideally it would probably be in the PictureContext - however it is mutable since it caches internal state. We could probably consider making the internal cache state a cell in the future to make this interface cleaner. webrender/src/picture.rs, line 282 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I do kind of see it as a transmute in this case. What we're doing here is saying that the rect in Picture space that all the primitive built up is now being considered in Local space of the picture itself. Do you mean by replacing by ScaleFactor(1.0) or something else? I can certainly do that if you think it's clearer? webrender/src/picture.rs, line 499 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Yep, the unclipped size is passed as f32 to a couple of methods. I think in the future we can probably further tidy this up to operate in float almost everywhere until we get the final render target size. webrender/src/prim_store.rs, line 170 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
By using ScaleFactor(1.0)? Or is there another way? webrender/src/prim_store.rs, line 527 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I think we wanted to rename the field inside BrushSegment. In this use case, the name actually makes sense. What this is saying is that any primitive that's not a brush, or any primitive that is a brush and has a surface, may end up needing a clip mask (i.e. pass-through pictures will never need a clip mask). webrender/src/prim_store.rs, line 1737 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Since it returns from the function, would a helper actually be any shorter in this case? webrender/src/prim_store.rs, line 2266 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/prim_store.rs, line 2744 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
It only returns false for not needing a clip mask if this is a pass through picture (i.e. it will never need a clip mask). The function could probably be named better, but I can't think of a good name right now :) |
|
Addressed most of the comments - there are a couple of questions that might need additional changes, otherwise I think this is ready to go now. |
* Pictures only calculate a local rect if they are not a pass-through primitive (i.e. if they have a surface). * Change batching code to use world rects. This avoids the need to do int conversions, and avoids the need to offset each bounding rect. * Change prim metadata to store world rects in floats, rather than integer screen rects. This integrates better with the plane splitting code. * Change clipping code to project to world space for complex clips. * Introduce SpaceMapper, a struct for efficiently converting between arbitrary coordinate systems. * Introduce Picture coordinate space, which is used to hold the local rect for a given Picture which has a render surface. * Prim metadata now only stores the clipped world rect. Most of the time the unclipped world rect isn't needed. It's only needed for Picture primitives that are drawing to a surface - so we calculate it on demand in Picture::prepare_for_render(). The major change here is that pictures now only calculate a local rect if they have a surface. Previously, all pictures tried to calculate a local rect. This caused problems because we were trying to map rects with partial transforms, and losing information as we then only considered the 2d projection within each picture. Now, we only calculate a local rect for pictures that actually have a surface. This fixes several reftests.
|
One of my concerns (about the clipping frustum) isn't addressed, but it doesn't have to be blocking the PR.
webrender/src/prim_store.rs, line 170 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
yes. Ideally, those scale factors are going to be constant somewhere and re-used. We can follow-up with this webrender/src/prim_store.rs, line 1737 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
there would be a single point of return (and either a |
|
@bors-servo r+ |
|
|
Various improvements towards correct handling of 3d transforms. * Pictures only calculate a local rect if they are not a pass-through primitive (i.e. if they have a surface). * Change batching code to use world rects. This avoids the need to do int conversions, and avoids the need to offset each bounding rect. * Change prim metadata to store world rects in floats, rather than integer screen rects. This integrates better with the plane splitting code. * Change clipping code to project to world space for complex clips. * Introduce SpaceMapper, a struct for efficiently converting between arbitrary coordinate systems. * Introduce Picture coordinate space, which is used to hold the local rect for a given Picture which has a render surface. * Prim metadata now only stores the clipped world rect. Most of the time the unclipped world rect isn't needed. It's only needed for Picture primitives that are drawing to a surface - so we calculate it on demand in Picture::prepare_for_render(). The major change here is that pictures now only calculate a local rect if they have a surface. Previously, all pictures tried to calculate a local rect. This caused problems because we were trying to map rects with partial transforms, and losing information as we then only considered the 2d projection within each picture. Now, we only calculate a local rect for pictures that actually have a surface. This fixes several reftests. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2995) <!-- Reviewable:end -->
|
|
gw3583 commentedAug 29, 2018
•
edited by larsbergstrom
The major change here is that pictures now only calculate a local rect if they have a surface. Previously, all pictures tried to calculate a local rect. This caused problems because we were trying to map rects with partial transforms, and losing information as we then only considered the 2d projection within each picture. Now, we only calculate a local rect for pictures that actually have a surface. This fixes several reftests.
This change is