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
Support double, groove, ridge borders in new border brush path. #2784
Conversation
Supersedes #2779, so closing that. |
This adds support for double, ridge and groove border styles to run through the new border brush path. I also moved a few GLSL functions around. This allows us to use them in cache shaders without including Avoiding that means we won't run into any shader compiler issues as we add the extra interpolators to this shader needed for dashing / dotting styles in the future. r? @kvark or @mrobinson |
Try run looks good - there are the expected (fuzziness required) failures from the previous border PR, and a number of new PASS results in R5. |
Added a follow up commit - this doesn't contain any functional changes, but is prep work for supporting dashing / dotting as border brushes (and it's a small optimization too). |
Review status: all files reviewed at latest revision, all discussions resolved. webrender/res/cs_border_segment.glsl, line 9 at r2 (raw file):
heh, I wonder if we hit any driver/angle/SPIRV-Cross issues with those arrays. And if we are to use them, wouldn't it be easier to just go webrender/res/cs_border_segment.glsl, line 12 at r2 (raw file):
bonus points for comments! 👍 💯 webrender/res/cs_border_segment.glsl, line 106 at r2 (raw file):
what is the "edge transition" here? webrender/res/cs_border_segment.glsl, line 160 at r2 (raw file):
can we move this switch out in a helper method? webrender/res/cs_border_segment.glsl, line 173 at r2 (raw file):
nit: double ";" at the end webrender/res/cs_border_segment.glsl, line 182 at r2 (raw file):
can we combine this switch with the one earlier? webrender/res/cs_border_segment.glsl, line 222 at r2 (raw file):
could you explain this bit? webrender/res/cs_border_segment.glsl, line 245 at r2 (raw file):
perhaps, we can take only the "mix_factor" away from this switch and then webrender/res/cs_border_segment.glsl, line 280 at r2 (raw file):
I'm worried a bit about using the vector indexing here. We need to check the HW requirements, also check if this doesn't affect shader performance (e.g. by throwing it under GPU ShaderAnalyzer). webrender/res/cs_border_segment.glsl, line 313 at r2 (raw file):
nit: could do webrender/res/cs_border_segment.glsl, line 351 at r2 (raw file):
The branching looks fairly heavy for the pixel shader, must be blowing up the register use. Not saying we should address this now, but surely keep an eye on border benchmarks. webrender/src/border.rs, line 1402 at r2 (raw file):
any reason for not calling it just Comments from Reviewable |
Review status: all files reviewed at latest revision, 10 unresolved discussions. webrender/res/cs_border_segment.glsl, line 9 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I think having them as two separate fields makes sense conceptually - each field is the 2 colors that make up each edge. Not sure if we'll see any shader compiler bugs :) webrender/res/cs_border_segment.glsl, line 12 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_border_segment.glsl, line 106 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Comment was out of date - updated. webrender/res/cs_border_segment.glsl, line 160 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_border_segment.glsl, line 182 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Done. webrender/res/cs_border_segment.glsl, line 222 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Yup, added a comment to describe what's going on here. webrender/res/cs_border_segment.glsl, line 245 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
It's not clear to me what this would look like - could you expand on that? webrender/res/cs_border_segment.glsl, line 280 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
I've used this a lot in the past and not hit any problems with it so far (it's also been in the GLSL specification since at least 2009 - see section 5.5 of https://www.khronos.org/files/opengles_shading_language.pdf), so hopefully we won't run into any problems with it. But you're probably right - we may well find some driver / gpu combination that doesn't like it. webrender/res/cs_border_segment.glsl, line 351 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Yep, it's definitely an expensive shader. Luckily it's not cached in the texture/render task cache, which should mitigate this. If we do ever see it in profiles, an easy fix is probably to have a "simple" border shader that handles the 99% common cases, and a complex border shader for the unlikely border styles. webrender/src/border.rs, line 1402 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
We have a BorderSegment enum already, unfortunately. It should be possible to tidy up a lot of the naming once I remove all the old border code (which I will be doing once I port dash + dot styles). Comments from Reviewable |
a82aec7
to
80815b1
Compare
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. webrender/res/cs_border_segment.glsl, line 245 at r2 (raw file): Previously, gw3583 (Glenn Watson) wrote…
Sure: float swizzled_factor;
switch (segment) {
case SEGMENT_TOP_LEFT: swizzled_factor = 0.0; break;
case SEGMENT_TOP_RIGHT: swizzled_factor = mix_factor;
case SEGMENT_BOTTOM_RIGHT: swizzled_factor = 1.0; break;
case SEGMENT_BOTTOM_LEFT: swizzled_factor = 1.0 - mix_factor; break;
default: swizzled_factor = 0.0;
};
vec4 c0 = mix(color[1], color[0], swizzled_factor);
vec4 c1 = mix(color[0], color[1], swizzled_factor); Comments from Reviewable |
80815b1
to
43c4743
Compare
Review status: 11 of 12 files reviewed at latest revision, 1 unresolved discussion. webrender/res/cs_border_segment.glsl, line 245 at r2 (raw file): Previously, kvark (Dzmitry Malyshau) wrote…
Ah, I thought you meant to somehow combine it with the mix below. Updated now :) Comments from Reviewable |
thank you! |
📌 Commit 43c4743 has been approved by |
Support double, groove, ridge borders in new border brush path. <!-- 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/2784) <!-- Reviewable:end -->
💔 Test failed - status-taskcluster |
@bors-servo retry |
Support double, groove, ridge borders in new border brush path. <!-- 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/2784) <!-- Reviewable:end -->
💔 Test failed - status-taskcluster |
@bors-servo retry |
Support double, groove, ridge borders in new border brush path. <!-- 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/2784) <!-- Reviewable:end -->
Also reduce clones of the brush segments. This is an optimization for the common case of a lot of similar borders. However, it mainly prep work for supporting dashing and dotting style support. In these cases, we may generate a large number of instances, and so it would be inefficient to generate these unconditionally. Instead, it's much more efficient to only generate them when there is no matching valid cached render task.
43c4743
to
9985a99
Compare
Rebased to include rawtest fixes. @bors-servo r=kvark |
📌 Commit 9985a99 has been approved by |
Support double, groove, ridge borders in new border brush path. <!-- 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/2784) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-taskcluster |
This change is