Skip to content
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 border corners with differing styles. #1199

Merged
merged 1 commit into from
May 4, 2017

Conversation

glennw
Copy link
Member

@glennw glennw commented May 4, 2017

This handles all border corners styles except those with
dashed and/or dotted styles. Those require changes to the
border clip mask shader, which will be done in a follow up.

The basic idea is to draw the corner twice, once for each style
and mask out the other side of the corner. This results in more
pixels being drawn than necessary, and can sometimes result in the
AA between the corner segments being slightly incorrect. Those
issues can be fixed at a later time.


This change is Reviewable

@glennw
Copy link
Member Author

glennw commented May 4, 2017

r? @kvark

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Just a few minor things, if you want perfection ;)
Anyhow, r=me

@@ -95,14 +123,16 @@ void main(void) {
color1 = border.colors[1];
vClipCenter = corners.tl_outer + border.radii[0].xy;
vClipSign = vec2(1.0);
set_radii(border.style.x,
style = select_style(prim.user_data.x, border.style.y, border.style.x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could have select_style accepting vec2 styles

border.radii[0].zw,
border.widths.zy,
adjusted_widths.zy);
set_edge_line(border.widths.zy,
corners.tr_outer,
vec2(-1.0, 1.0));
style = int(border.style.y);
edge_distances = vec4(p1.x - adjusted_widths.z,
p0.y + adjusted_widths.y,
p1.x - border.widths.z + adjusted_widths.z,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line could use some inv_adjusted_widths too

border.radii[1].xy,
border.widths.zw,
adjusted_widths.zw);
set_edge_line(border.widths.zw,
corners.br_outer,
vec2(-1.0, -1.0));
style = int(border.style.z);
edge_distances = vec4(p1.x - adjusted_widths.z,
p1.y - adjusted_widths.w,
p1.x - border.widths.z + adjusted_widths.z,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, this could use inv_adjusted_widths, even in a vectorized (short) form

batch.add_instance(base_instance.build(border_segment, 0, 0));
for (i, instance_kind) in border_cpu.corner_instances.iter().enumerate() {
let sub_index = i as i32;
match *instance_kind {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this match could be simplified if it only returned &[BorderCornerSide]

This handles all border corners styles except those with
dashed and/or dotted styles. Those require changes to the
border clip mask shader, which will be done in a follow up.

The basic idea is to draw the corner twice, once for each style
and mask out the other side of the corner. This results in more
pixels being drawn than necessary, and can sometimes result in the
AA between the corner segments being slightly incorrect. Those
issues can be fixed at a later time.
@glennw
Copy link
Member Author

glennw commented May 4, 2017

@kvark Thanks - fixed the select_style function - will fix the other nits up as follow ups to tidy that shader code up :)

@bors-servo r=kvark

@bors-servo
Copy link
Contributor

📌 Commit c1efd22 has been approved by kvark

@bors-servo
Copy link
Contributor

⌛ Testing commit c1efd22 with merge e2e07a0...

bors-servo pushed a commit that referenced this pull request May 4, 2017
Support border corners with differing styles.

This handles all border corners styles except those with
dashed and/or dotted styles. Those require changes to the
border clip mask shader, which will be done in a follow up.

The basic idea is to draw the corner twice, once for each style
and mask out the other side of the corner. This results in more
pixels being drawn than necessary, and can sometimes result in the
AA between the corner segments being slightly incorrect. Those
issues can be fixed at a later time.

<!-- 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/1199)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: kvark
Pushing e2e07a0 to master...

@bors-servo bors-servo merged commit c1efd22 into servo:master May 4, 2017
@staktrace
Copy link
Contributor

@glennw I think this patch does actually trigger all those test failures in the gecko try push we were talking about yesterday (tracked in bug 1363683). It looks like possibly an infinite loop somewhere inside the render function - or at least something that causes the render function take upwards of 5 minutes to run, at which point the timeout kills the test.

I was able to reproduce locally on the gecko layout/reftests/abs-pos/table-3.html reftest. I interrupted with gdb while it was inside the render function and got a backtrace: https://gist.github.com/staktrace/22ea886d20afb334c3b80920ec7c9d0b

@kvark
Copy link
Member

kvark commented May 11, 2017

@staktrace that is worrisome... I re-inspected the code and didn't see a potential cause of endless loops. Perhaps, the hang/delay is coming from the driver or the hardware doesn't like the new code for some reason. I think we should back the PR out and try reproducing your case on Gecko locally.

@glennw
Copy link
Member Author

glennw commented May 11, 2017

@staktrace @kvark Hmm, that backtrace does indeed suggest the shader change is causing some kind of issue inside llvmpipe. I'm guessing that the shader change has triggered a bug in mesa / llvmpipe :(

@glennw
Copy link
Member Author

glennw commented May 11, 2017

@staktrace @kvark I will try to reproduce this locally on llvmpipe today.

@glennw
Copy link
Member Author

glennw commented May 11, 2017

I imagine it will just be some tweak to the shader needed to avoid triggering the bug in mesa / llvm - hopefully.

@glennw
Copy link
Member Author

glennw commented May 12, 2017

@staktrace @kvark

I reproduced this locally. It appears to be a bug in the shader compiler in mesa / llvm. I've opened a PR here #1242 which works around the hang by slightly tweaking the structure of the shader.

It shouldn't have any functional effect, but fixes the problem for me. Is the simplest way to test this just to get it merged and try to do an update?

@glennw glennw deleted the corners5 branch May 12, 2017 04:36
@staktrace
Copy link
Contributor

If the PR can be applied (without too much rebasing) directly onto the copy of webrender in mozilla-central or graphics, that would be the best thing to push to try - that way we start from a known good revision and just test this change in isolation. However if it depends on other things that landed since the last WR update into gecko, or is otherwise problematic to rebase, then it's probably easiest to just get it merged and my next simulated WR update will test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants