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 upUse picture caching for text shadows. #3270
Conversation
|
r? @kvark Initial try run looks good: I also kicked off a pending try on all platforms: I'm not sure how good our CI testing is for things that cached and then invalidated. It seems to work fine to me from some manual browsing, but it'd be worth some sanity checks of the cache invalidation logic to see if it seems sound to you. |
|
Looks like there is a failing crash test on OSX, but I haven't been able to reproduce locally yet. |
|
Both of the crash test failures on OS X are explicit panics due to render task size. However, one of the tests doesn't appear to have any text shadows at all, so it may be something unrelated to this patch. Still investigating. |
|
Ah, it seems that Gecko sometimes provides an extremely large text shadow in the chrome on the first frame or two, and this patch was not catching that. Updated the patch and kicked off a new try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=05153326984fe8dad10b663ee41829781789a1b1 Hopefully that should resolve those crash test failures. |
|
|
|
Rebased. The latest try run looks good - just one new PASS in |
|
|
|
Rebased. |
|
|
This patch allows text shadows to be cached and persisted both between frames and new display lists, in the texture cache. Previously, text shadows could be cached between frames, but would be flushed and redrawn when a new display list was processed. The primitive and clip interning system is used to determine when the contents of a cached picture is valid. For now, this is only applied in very limited scenarios, in order to ensure the core functionality is correct (specifically, blur filters that contain glyphs and line decorations, which covers most text shadows). In the future, this will be expanded to cover (a) more primitive types (b) more surface / filter effects and (c) at a finer granularity to allow partial picture caching (tiles). As part of this change, we can remove all references to the global scene id, as this is no longer required. This brings the GPU time in the cloud ad [1] from 43 ms down to 8 ms for me. This is still higher than we want, due to the very high number of cached text shadows that get composited. This should be resolved as we support nested picture caching. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1436193
|
Rebased. |
|
@gw3583 sorry about the delay, reviewing it now. |
|
Looks great! Concerns below:
webrender/src/freelist.rs, line 75 at r1 (raw file):
this is confusing. There is webrender/src/intern.rs, line 80 at r1 (raw file):
basic question: why is the UID needed in addition to webrender/src/intern.rs, line 85 at r1 (raw file):
nit: just webrender/src/picture.rs, line 444 at r1 (raw file):
maybe rename to webrender/src/prim_store.rs, line 126 at r1 (raw file):
nit: I wonder if we should make it a method of the cst: webrender/src/render_task.rs, line 1156 at r1 (raw file):
where does the new code call webrender/src/surface.rs, line 70 at r1 (raw file):
if we are quantifying, why not storing integers as the result? That would avoid the webrender/src/surface.rs, line 134 at r1 (raw file):
nit: rename to webrender/src/surface.rs, line 164 at r1 (raw file):
is it an ordered list or really just a set? webrender/src/surface.rs, line 202 at r1 (raw file):
slightly confusing that it's a set that has webrender/src/surface.rs, line 221 at r1 (raw file):
ok, this is really scary (to compare indices for ordering). Could you explain this part please? webrender/src/surface.rs, line 296 at r1 (raw file):
if the coordinate systems match, there can still be offset/scale applied, right? this looks like we are ignoring it wrench/reftests/filters/filter-blur.png, line 0 at r1 (raw file): wrench/reftests/filters/reftest.list, line 17 at r1 (raw file):
why do we have more targets now? |
webrender/src/freelist.rs, line 75 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
There were some other changes made to Freelist recently, that introduced the invalid epoch. I updated this PR to make use of that. webrender/src/intern.rs, line 80 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Epoch advances each time a new scene is built, but we want an ID that is stable across scene builds. webrender/src/intern.rs, line 85 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Fixed. webrender/src/picture.rs, line 444 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Fixed webrender/src/prim_store.rs, line 126 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I think it's probably fine as is, but can make that change if you'd prefer? It might make sense to actually move the entire CoordinateSpaceMapping definition to be a separate file / module. webrender/src/render_task.rs, line 1156 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
These are handled by the return value of the retain closure? webrender/src/surface.rs, line 70 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
We could, although I'm not sure if the casting to / from integers would be more costly than just quantizing and hashing floats. Perhaps something to consider as a follow up? webrender/src/surface.rs, line 134 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Fixed webrender/src/surface.rs, line 164 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
It's an ordered list. We want the cache key to be different if we receive a picture that has the same primitives but in a different ordering. webrender/src/surface.rs, line 202 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Renamed to relevant_spatial_nodes webrender/src/surface.rs, line 221 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
That first condition just seems wrong, I'm not sure why that was there. The second check is the same condition that the clip node collector uses (that is, any clip nodes positioned by a node earlier in the hierarchy than the picture itself get applied when the surface is composited). I'll kick off another try run with this change just to make sure it doesn't break anything. webrender/src/surface.rs, line 296 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
That will still actually be handled - the CoordinateSpaceMapping constructor will create a ScaleOffset variant, which will be converted to the appropriate key. wrench/reftests/filters/filter-blur.png, line at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
We temporarily regress here, in that picture caching of blurs only works on text shadows, and not arbitrary pictures. This will be fixed as we port more primitives to be interned. wrench/reftests/filters/reftest.list, line 17 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
These tests no longer get drawn into the texture cache, for now. They get drawn as normal render tasks, until we port solid primitives to be interned. |
|
The updated try run looks good. |
|
Thanks for the updates!
webrender/src/render_task.rs, line 1156 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
d'oh, indeed :) webrender/src/surface.rs, line 70 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
sure! would be good to have a small comment about this in the code webrender/src/surface.rs, line 221 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
I was looking at this node collector code earlier, and I'm still worried about this code. The fact that it was there for a while and the try pushes are green isn't enough to prove the it's correct :) What is the exact semantics that you expect from spatial_node_index1 < spatial_node_index2 comparison? If a node was added later than another node, I don't think this us much insight about how they are placed. We can definitely say that spatial_node_index1 is not a child of spatial_node_index2, but that's pretty much it? webrender/src/surface.rs, line 296 at r1 (raw file): Previously, gw3583 (Glenn Watson) wrote…
but we aren't invoking the |
webrender/src/render_task.rs, line 1156 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/src/surface.rs, line 70 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Added a comment. webrender/src/surface.rs, line 221 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
This code is definitely not nice - it's mostly an artifact of trying to make things work without changes to gecko / WR APIs. However, with your work on Gecko clip changes, we should actually discuss this and fix it properly so that the implementation details are not so hacky. Having said that, let me try to describe what this and the clip node collector code assume. As you said above, what we can infer from the indices is that a smaller index is a parent (or an unrelated ancestor, but this doesn't happen in practice, even though the API doesn't enforce this). And if the clip node is positioned by a parent of the stacking context, then we apply the clip to the stacking context as a whole, rather than the individual items. Happy to discuss on IRC if you'd prefer - it's a complex issue to try and describe. webrender/src/surface.rs, line 296 at r1 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Oh, you're right - that code was totally bogus! Not only was the raster key wrong, I was storing it in the descriptor and not the cache key, so it wouldn't invalidate any caches anyway, oops! So, I've added it to the cache key, and now the logic says that if we end up with a scale-offset transform key, zero out the offset. This means that we don't care / invalidate a cached surface if the only difference is the offset between the two raster transforms. |
|
Kicked off another try run with those changes: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ce79c55379c611432197d584d2942dbb767d6db7 |
|
@kvark Even if try passes and you're happy with the changes above, let's hold off on merging this for now, as it sounds like we might need some urgent fixes for a potential texture cache corruption issue. |
|
Looks good now! I still want the node indices comparison to be improved, but we already have it in node collector, so this PR isn't introducing a new flaw.
webrender/src/surface.rs, line 221 at r1 (raw file):
This is my worry. We should at the very minimum put a debug assertion in place to prevent this. Ideally, not comparing the node indices at all :) |
|
@kvark Sounds good, thanks! I'll get this merged tonight / tomorrow morning then |
|
We should be fine to land this now, since #3285 is in the queue and also in gecko inbound. @bors-servo r=kvark |
|
|
Use picture caching for text shadows. This patch allows text shadows to be cached and persisted both between frames and new display lists, in the texture cache. Previously, text shadows could be cached between frames, but would be flushed and redrawn when a new display list was processed. The primitive and clip interning system is used to determine when the contents of a cached picture is valid. For now, this is only applied in very limited scenarios, in order to ensure the core functionality is correct (specifically, blur filters that contain glyphs and line decorations, which covers most text shadows). In the future, this will be expanded to cover (a) more primitive types (b) more surface / filter effects and (c) at a finer granularity to allow partial picture caching (tiles). As part of this change, we can remove all references to the global scene id, as this is no longer required. This brings the GPU time in the cloud ad [1] from 43 ms down to 8 ms for me. This is still higher than we want, due to the very high number of cached text shadows that get composited. This should be resolved as we support nested picture caching. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1436193 <!-- 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/3270) <!-- Reviewable:end -->
|
|
zptan
commented
Nov 8, 2018
|
@bors-servo retry |
|
@zptan: |
|
@bors-servo retry |
Use picture caching for text shadows. This patch allows text shadows to be cached and persisted both between frames and new display lists, in the texture cache. Previously, text shadows could be cached between frames, but would be flushed and redrawn when a new display list was processed. The primitive and clip interning system is used to determine when the contents of a cached picture is valid. For now, this is only applied in very limited scenarios, in order to ensure the core functionality is correct (specifically, blur filters that contain glyphs and line decorations, which covers most text shadows). In the future, this will be expanded to cover (a) more primitive types (b) more surface / filter effects and (c) at a finer granularity to allow partial picture caching (tiles). As part of this change, we can remove all references to the global scene id, as this is no longer required. This brings the GPU time in the cloud ad [1] from 43 ms down to 8 ms for me. This is still higher than we want, due to the very high number of cached text shadows that get composited. This should be resolved as we support nested picture caching. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1436193 <!-- 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/3270) <!-- Reviewable:end -->
|
|
gw3583 commentedNov 5, 2018
•
edited by larsbergstrom
This patch allows text shadows to be cached and persisted both
between frames and new display lists, in the texture cache.
Previously, text shadows could be cached between frames, but would
be flushed and redrawn when a new display list was processed.
The primitive and clip interning system is used to determine when
the contents of a cached picture is valid.
For now, this is only applied in very limited scenarios, in order
to ensure the core functionality is correct (specifically, blur
filters that contain glyphs and line decorations, which covers
most text shadows). In the future, this will be expanded to cover
(a) more primitive types (b) more surface / filter effects and
(c) at a finer granularity to allow partial picture caching (tiles).
As part of this change, we can remove all references to the global
scene id, as this is no longer required.
This brings the GPU time in the cloud ad [1] from 43 ms down to
8 ms for me. This is still higher than we want, due to the very high
number of cached text shadows that get composited. This should be
resolved as we support nested picture caching.
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1436193
This change is