-
Couldn't load subscription status.
- Fork 301
Pass dot / dash locations to clip shader in the VAO #2652
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
Conversation
|
@glennw I'd love to get your feedback on my approach here. In particular I'm curious if I should be doing more to discards dots and dashes in the vertex shader. I'm also curious if my method of modifying the ClipMaskInstance data structure using GLSL preprocessor directives makes sense or if there is a more elegant method. I've decided to use a single data structure (a data blob like primitives use) for both dots and dashes. This seems like it would give a minor improvement to batching and prevent having to compile separate shaders for dots and dashes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on correctness, but I can on the general approach. I like where it's going, and I think we can go even further than that (perhaps, as a follow-up).
The idea is that maybe we don't even need the per-instance data for dots/dashes (and image tiles, for the matter). Perhaps, we could compute all the parameters in vertex shaders based on the vertex and instance ID.
For ellipses, it appears that we can efficiently compute the path across the curve given the E function. Since it doesn't depend on ellipse size, we could just bake it into a shared texture (say, 1024x1) that we linearly sample in VS.
|
Yup, this seems like a good general approach to me (I haven't looked in super detail). I'm not sure that we need any of the pre-processor changes you mentioned - each clip shader will know the exact vertex format / kind it's reading (e.g. clip_dot vs clip_rect shader), so it's probably fine to define a GLSL type for each of those? I think we do need to do some clipping work for dots / dashes. Since dots and dashes are drawn as geometry, it's possible they may extend outside the task rect of the clip mask, I think. Ideally we can do this in the VS (cull the entire dot if it's outside the task rect), but I think we'll probably need a FS clip as well, to ensure that partial dots don't write outside the task rect. Another option might be to just use a scissor rect (and disable batching) on clip masks that have dots / dashes, since they are quite rare. This wouldn't be ideal, but might be fine for a first pass. The case where we will actually need clipping for this is quite rare, but I'm fairly sure it can occur - e.g. if a border with dots has a clip chain that results in part of the border being removed? I like the idea of @kvark 's suggestion - but I'm a little wary of it. As we discussed previously, the existing Gecko code for dot / dash placement is absolutely massive. For now, we're assuming we can get away with a fairly simple placement algorithm, which would be fine to evaluate in a VS / texture, but if we end up needing to do something more complex, that won't be feasible. |
|
☔ The latest upstream changes (presumably #2642) made this pull request unmergeable. Please resolve the merge conflicts. |
23c4951 to
c233940
Compare
|
☔ The latest upstream changes (presumably #2651) made this pull request unmergeable. Please resolve the merge conflicts. |
c233940 to
290b7bd
Compare
|
@glennw @kvark Thanks for looking at the PR. I've updated it to improve clipping in the fragment shader. Now the mask rect is clamped to the task rect, which I think properly handles partial dots. A good follow-up for this version would be to produce vertices representing a tight bounding rectangle of the dot or dash. I'm working on that now, but this version seems to fix the issues raised in the bug while maintaining the performance of the old approach. As far as the shader goes, the dot/dash shader shares almost every input variable with the normal clip mask shader, so I used the GLSL preprocessor to reuse the |
|
☔ The latest upstream changes (presumably #2663) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This patch is ready to go, except I'm seeing a timeout during the crashtests: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1f61787a13f729be243398b316548031ad5cbdb3&selectedJob=174110305 When I run these tests locally, another crashtest times out, both with and without my changes. I'm a bit stumped what is causing this behavior. |
290b7bd to
fae38bc
Compare
|
I'm still having trouble debugging the crashtest timeout (though the Gecko tree is closed). I'm hoping to make some progress once it reopens. |
fae38bc to
3809c8d
Compare
|
@glennw I was finally able to get a passing try run for Gecko (modulo a few intermittent failures): I had to make some changes in order to make this happen:
Thanks! |
|
Looks like I spoke too soon. This does seem to change the details of the fuzziness (an already very fuzzy test) for layout/reftests/css-break/box-decoration-break-with-inset-box-shadow-1.html. It seems reasonable that we can just update the fuzz for this one. |
|
Reviewed 7 of 7 files at r1. Comments from Reviewable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, once we get sign-off from @staktrace on the fuzziness change.
|
I'm ok with the box-decoration-break-with-inset-box-shadow-1.html fuzz since that's just increasing pre-existing fuzziness by a little bit. But the position-sticky/inline-4.html fuzz is new, and has a user-visible difference (one of the dots is off). Is this expected, or is there something wrong with the test, or something else? |
|
☔ The latest upstream changes (presumably #2679) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@staktrace Sorry, it seems the |
3809c8d to
8c5a85b
Compare
|
Okay. After a lot of banging my head against this issue, I think I have figured out what was going on! The first versions of this PR changed the alignment of the VAO for dots and dashes. When I restored the unused element of the ClipMaskInstance the reference test failures disappeared. This also makes the diff much smaller. Here is the latest Gecko try job: I only see two seemingly unrelated intermittent failures. |
|
r? @glennw (once again for the new branch) |
|
Reviewed 6 of 7 files at r2. webrender/res/cs_clip_border.glsl, line 52 at r2 (raw file):
We can remove segment as a param from here. webrender/res/cs_clip_border.glsl, line 61 at r2 (raw file):
Same webrender/src/batch.rs, line 1788 at r2 (raw file):
Does segment get used here at all, or could we just leave it as the base instance? Comments from Reviewable |
|
A couple of minor nits, r=me after those are addressed. |
|
Thanks for the review! Review status: all files reviewed at latest revision, 3 unresolved discussions. webrender/res/cs_clip_border.glsl, line 52 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
Okay. I'll fix this. webrender/src/batch.rs, line 1788 at r2 (raw file): Previously, glennw (Glenn Watson) wrote…
The shader understands the 0 segment as the clear, so this just needs to be != 0. I can add a comment here. Comments from Reviewable |
Instead of loading dot and dash positions into the GPU cache, send them as VAO arguments. This avoids exceeding the maximum GPU cache block size with very large border corners with hundreds or thousands of dot / dashes. This fixes the first panic from servo#2469, though performance is still abysmal. Later changes can address performance issues.
8c5a85b to
429cc01
Compare
|
@bors-servo r=glennw |
|
📌 Commit 429cc01 has been approved by |
Pass dot / dash locations to clip shader in the VAO Instead of loading dot and dash positions into the GPU cache, send them as VAO arguments. This avoids exceeding the maximum GPU cache block size with very large border corners with hundreds or thousands of dot / dashes. This fixes the first panic from #2469, though performance is still abysmal. Later changes can address performance issues. <!-- 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/2652) <!-- Reviewable:end -->
|
☀️ Test successful - status-appveyor, status-taskcluster |
Instead of loading dot and dash positions into the GPU cache, send them
as VAO arguments. This avoids exceeding the maximum GPU cache block
size with very large border corners with hundreds or thousands of dot /
dashes.
This fixes the first panic from #2469, though performance is still
abysmal. Later changes can address performance issues.
This change is