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

Remove aligned gradient shader, port to brush. #2441

Merged
merged 3 commits into from Feb 21, 2018

Conversation

@glennw
Copy link
Member

glennw commented Feb 19, 2018

Instead, push aligned gradients through the linear angle gradient
shader (for now).

This will simplify converting linear gradient code over to be
a brush shader. The optimization here was always a bit dubious
(it made more sense when we first started WR, when the angle
gradient shader was more expensive than it is now).

Instead, what we can do in the future if gradients ever show
up in the GPU profile is support vertex colors for the rectangle
shader and decompose simple aligned gradients into a series
of rectangle segments with different vertex colors.

The benefit of this is reduced shader changes and simpler batching.


This change is Reviewable

@glennw
Copy link
Member Author

glennw commented Feb 19, 2018

Added a follow up commit that switches the tiling / repeat of linear gradients to be done on CPU rather than in the shader (exactly the same implementation details as how this was done for radial gradients previously).

@glennw
Copy link
Member Author

glennw commented Feb 19, 2018

Added another commit that ports the linear gradient primitive to be a brush shader.

@glennw glennw changed the title Remove aligned gradient shader. Remove aligned gradient shader, port to brush. Feb 19, 2018
@glennw
Copy link
Member Author

glennw commented Feb 19, 2018

The overall summary of this PR:

  • Remove aligned gradient shader and primitive (there's better ways to do fast path gradients, if we need to, in the future).
  • Rename angle gradient -> linear gradient, which is more accurate.
  • Switch linear gradient tile/repeat to be done on CPU, exactly as radial gradients now work.
  • Port angle gradient shader to brush primitive, allowing segments for linear gradients.

Pending try:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4a4739d322e1588e02f396e7b3f6db23a00d8063
https://hg.mozilla.org/try/rev/4a4739d322e1588e02f396e7b3f6db23a00d8063

@kvark
Copy link
Member

kvark commented Feb 20, 2018

Looks sane to me!
One thing I'd like to be changed (possibly in a follow-up), and also there appear to be failures in the last try push, related to border shaders and input-radio-XXX.


Reviewed 2 of 7 files at r1, 1 of 5 files at r2, 8 of 8 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


webrender/tests/angle_shader_validation.rs, line 104 at r3 (raw file):

    Shader {
        name: "brush_radial_gradient",
        features: &[],

let's have at least one of them with dithering feature


Comments from Reviewable

@glennw glennw force-pushed the glennw:remove-aligned-gradient branch from 1da09d2 to 7b06868 Feb 20, 2018
@glennw
Copy link
Member Author

glennw commented Feb 20, 2018

@kvark Thanks for the review! I updated the validation to include the dither feature. The reftest failures are from previous PRs (the input/radio are from the local-clip-rect + box-shadow PR, and the border-radii are from the ellipse distance optimization PR). Both are fuzzed in the latest WR update.

@kvark
Copy link
Member

kvark commented Feb 20, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

📌 Commit 7b06868 has been approved by kvark

bors-servo added a commit that referenced this pull request Feb 20, 2018
Remove aligned gradient shader, port to brush.

Instead, push aligned gradients through the linear angle gradient
shader (for now).

This will simplify converting linear gradient code over to be
a brush shader. The optimization here was always a bit dubious
(it made more sense when we first started WR, when the angle
gradient shader was more expensive than it is now).

Instead, what we can do in the future if gradients ever show
up in the GPU profile is support vertex colors for the rectangle
shader and decompose simple aligned gradients into a series
of rectangle segments with different vertex colors.

The benefit of this is reduced shader changes and simpler batching.

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

bors-servo commented Feb 20, 2018

Testing commit 7b06868 with merge ffce1c0...

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

💔 Test failed - status-travis

@glennw
Copy link
Member Author

glennw commented Feb 20, 2018

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

The latest upstream changes (presumably #2444) made this pull request unmergeable. Please resolve the merge conflicts.

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

🔒 Merge conflict

gw3583 added 3 commits Feb 19, 2018
Instead, push aligned gradients through the linear angle gradient
shader (for now).

This will simplify converting linear gradient code over to be
a brush shader. The optimization here was always a bit dubious
(it made more sense when we first started WR, when the angle
gradient shader was more expensive than it is now).

Instead, what we can do in the future if gradients ever show
up in the GPU profile is support vertex colors for the rectangle
shader and decompose simple aligned gradients into a series
of rectangle segments with different vertex colors.

The benefit of this is reduced shader changes and simpler batching.
@glennw glennw force-pushed the glennw:remove-aligned-gradient branch from 7b06868 to 1c04b4f Feb 20, 2018
@glennw
Copy link
Member Author

glennw commented Feb 20, 2018

Rebased.

@bors-servo r=kvark

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

📌 Commit 1c04b4f has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Feb 20, 2018

Testing commit 1c04b4f with merge 2d2d7b7...

bors-servo added a commit that referenced this pull request Feb 20, 2018
Remove aligned gradient shader, port to brush.

Instead, push aligned gradients through the linear angle gradient
shader (for now).

This will simplify converting linear gradient code over to be
a brush shader. The optimization here was always a bit dubious
(it made more sense when we first started WR, when the angle
gradient shader was more expensive than it is now).

Instead, what we can do in the future if gradients ever show
up in the GPU profile is support vertex colors for the rectangle
shader and decompose simple aligned gradients into a series
of rectangle segments with different vertex colors.

The benefit of this is reduced shader changes and simpler batching.

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

bors-servo commented Feb 21, 2018

☀️ Test successful - status-appveyor, status-taskcluster, status-travis
Approved by: kvark
Pushing 2d2d7b7 to master...

@bors-servo bors-servo merged commit 1c04b4f into servo:master Feb 21, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 4 files, 1 discussion left (glennw, kvark)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@glennw glennw deleted the glennw:remove-aligned-gradient branch Feb 21, 2018
@glennw
Copy link
Member Author

glennw commented Feb 21, 2018

@staktrace Ugh, there are some gradient reftest failures I missed seeing in the try push above - these are going to cause failures in the wr-future bug. I'll look into these as soon as possible (they weren't there initially - possibly a rebasing mistake I made or something like that).

@glennw
Copy link
Member Author

glennw commented Feb 21, 2018

Interestingly, they only appear in a debug build - which might be how I managed to miss them. I also can't reproduce locally with a release build. Compiling a debug build now.

@glennw
Copy link
Member Author

glennw commented Feb 21, 2018

Can't reproduce locally with rustc debug enabled. Trying another build with full debug enabled.

@staktrace
Copy link
Contributor

staktrace commented Feb 21, 2018

I'll do a local debug build as well to see if I can repro.

@staktrace
Copy link
Contributor

staktrace commented Feb 21, 2018

I've been able to reproduce a failure in layout/reftests/css-gradients/height-dependence-2.html but very sporadically. I tried getting WR captures of it but they came out blank, so I don't know how useful that will be. The failure as reported by the reftest harness shows the "pad pad pad" text not running all the way to the bottom of the rect in the test image (there's only 16 lines of it vs. 32 in the reference image). I did, however, get a rr recording of the failure (since I reproduced it with rr's chaos mode). If you have any suggestions on how to debug it I'm all ears.

@staktrace
Copy link
Contributor

staktrace commented Feb 21, 2018

height-dependence-2-captures.zip

^ the captures along with the reftest harness output (for use in reftest analyzer) if they're of any use to anybody.

@kvark
Copy link
Member

kvark commented Feb 21, 2018

Are you sure the breakage is caused by this PR though? Gradients don't appear to be rendering any differently between the captures. And the PR doesn't seem to touch anything on either the clip chain side or glyph positioning.

@glennw
Copy link
Member Author

glennw commented Feb 21, 2018

We're not sure it's this PR - we are bisecting a couple of patches to find the cause.

@staktrace
Copy link
Contributor

staktrace commented Feb 21, 2018

@glennw
Copy link
Member Author

glennw commented Feb 21, 2018

Yup, that seems fairly conclusive. There's 3 commits in that patch, so I'll try to narrow down the cause there.

@glennw
Copy link
Member Author

glennw commented Feb 22, 2018

@glennw
Copy link
Member Author

glennw commented Feb 22, 2018

Those try pushes suggest that it's likely to be the middle commit (1628f2e) that is causing the problem. It's possible that may be exposing a race condition elsewhere.

@glennw
Copy link
Member Author

glennw commented Feb 22, 2018

The height-dependence-2 test has a gradient that is 1px wide and gets repeated across the screen, resulting in 1280 primitives being generated. This results in a large number of gradients being added to the GPU cache. My current theory is that this is exposing a bug in the GPU cache, perhaps related to resizing the GPU cache texture.

@glennw
Copy link
Member Author

glennw commented Feb 22, 2018

Oh, I see what the problem is. Working on a fix now.

@kvark
Copy link
Member

kvark commented Feb 22, 2018

Speaking of GPU cache issues, we are lacking the appropriate toolset - #2453
WR capturing helps, but text format is not the best for inspecting GPU cache data.

glennw pushed a commit to glennw/webrender that referenced this pull request Feb 22, 2018
This is a potential fix for the intermittent failures here:
servo#2441 (comment)

I still can't reproduce them locally. However, I could see that the
GPU cache size in that test was getting dangerously close to the
maximum size of the texture supported by the GL implementation.

That would fit with the issues we're seeing on CI, where there
seems to be items not being drawn, and they are affected even
though the test in question doesn't draw any gradients.

This is not a very elegant fix - however it will hopefully fix
the issues we are seeing on CI for now. We can revisit this
later to consider a better fix.
@glennw
Copy link
Member Author

glennw commented Feb 22, 2018

Potential fix here - #2454 - try run in progress to see if it helps.

bors-servo added a commit that referenced this pull request Feb 22, 2018
Share gradient GPU cache entries for repeated gradient primitives.

This is a potential fix for the intermittent failures here:
#2441 (comment)

I still can't reproduce them locally. However, I could see that the
GPU cache size in that test was getting dangerously close to the
maximum size of the texture supported by the GL implementation.

That would fit with the issues we're seeing on CI, where there
seems to be items not being drawn, and they are affected even
though the test in question doesn't draw any gradients.

This is not a very elegant fix - however it will hopefully fix
the issues we are seeing on CI for now. We can revisit this
later to consider a better fix.

<!-- 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/2454)
<!-- Reviewable:end -->
@kvark
Copy link
Member

kvark commented Feb 22, 2018

I confirm this is a problem with exceeding maximum texture size of 8K.
Also see #2459 to have run-time checks for it.

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

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.