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

Use the texture filtering hardware to reduce the number of sample operations in the blur shader. #3122

Merged
merged 1 commit into from Dec 6, 2018

Conversation

pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Sep 25, 2018

Linear filtering allows us to evaluate the formula

k₀c₀ + k₁c₁                 (Equation 1)

where c₀ and c₁ are the colors of adjacent texels and k₀ and k₁ are arbitrary
factors (in this case, the results of evaluating the Gaussian function) with a
single lookup. Linear filtering evaluates the following expression for some t
between 0 and 1:

lerp(c₀, c₁, t)

It can be shown algebraically that Equation 1 is equivalent to:

             ⎛           k₁  ⎞
(k₀ + k₁)lerp⎜c₀, c₁, ───────⎟
             ⎝        k₀ + k₁⎠

Which can be readily evaluated by letting t = k₁/(k₀ + k₁) and performing a
texture lookup.

This results in some minor visual differences because we always compute an even
number of pixels on each side (i.e. the support is now always rounded up to
the nearest even number of pixels), whereas before we might have evaluated an
odd number of pixels. All differences should therefore be minor quality
improvements.

Don't merge this yet; I want to run tests and a try build.


This change is Reviewable

@pcwalton
Copy link
Contributor Author

@pcwalton
Copy link
Contributor Author

Yeah, this looks bad. I'll try to match the existing rendering more closely.

@mstange
Copy link
Contributor

mstange commented Sep 26, 2018

If then new blur is just as "correct" as the software reference blur, it's probably not worth making them match. It would be better to spend the time on making sure that WebRender is used for both the test and the reference (by making SVG filters go through WebRender.)

pcwalton added a commit to pcwalton/webrender that referenced this pull request Sep 26, 2018
I'm pretty confident this is correct--it's either just as accurate or more
accurate than the current implementation--so it'll let me sort out which test
failures, if any, from servo#3028 and servo#3122 are true regressions.
pcwalton added a commit to pcwalton/webrender that referenced this pull request Sep 26, 2018
I'm pretty confident this is correct--it's either just as accurate or more
accurate than the current implementation--so it'll let me sort out which test
failures, if any, from servo#3028 and servo#3122 are true regressions.
bors-servo pushed a commit that referenced this pull request Sep 26, 2018
Round blur support up to the nearest even number of pixels.

I'm pretty confident this is correct--it's either just as accurate or more
accurate than the current implementation--so it'll let me sort out which test failures, if any, from #3028 and #3122 are true regressions.

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

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

@pcwalton pcwalton force-pushed the blur-filtering branch 2 times, most recently from 4759586 to 58814ff Compare September 27, 2018 02:46
@pcwalton
Copy link
Contributor Author

pcwalton commented Sep 27, 2018

Much better now. Just one test has imperceptible differences, probably due to minor rounding differences introduced by algebraic manipulation.

@pcwalton
Copy link
Contributor Author

@pcwalton
Copy link
Contributor Author

Just a few minor fuzziness differences on try. This looks good.

r? @gw3583

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.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @gw3583)

@kvark
Copy link
Member

kvark commented Sep 28, 2018

Windows reftests are failing though.

@gw3583
Copy link
Contributor

gw3583 commented Oct 29, 2018

@pcwalton It looks like this was basically ready to go but then got overlooked. If that's the case, I guess rebasing and doing a try would be good to make sure it's still fine, and then we can get this merged?

@pcwalton
Copy link
Contributor Author

It was ready to go but I wasn't sure about try results. Let me try again.

@gw3583
Copy link
Contributor

gw3583 commented Nov 20, 2018

@pcwalton Did you get a chance to kick off another try for this?

@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 4, 2018

@bors-servo
Copy link
Contributor

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

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

From a quick look at the try run:

1 and 2 failures look like unrelated intermittents.
R1 and R3 on OSX are new passes (less fuzzy than the current annotations).
R7 on Linux is a new fail - the max pixel difference is the same as the current reftest annotations, but there are more pixels that need to be marked fuzzy.

I think these changes are fine, but we should get @staktrace or @jrmuizel to double check. Also looks like it needs a rebase to fix the conflicting reftest image.

@staktrace
Copy link
Contributor

From a quick look at the try run:

1 and 2 failures look like unrelated intermittents.

Yes although I don't see these failures anywhere else so I'd like to see another try push rebased on central to confirm. And this try push was actually based on mozilla-beta rather than mozilla-central, so it may not even be accurate in terms of what it shows.

R1 and R3 on OSX are new passes (less fuzzy than the current annotations).
R7 on Linux is a new fail - the max pixel difference is the same as the current reftest annotations, but there are more pixels that need to be marked fuzzy.

Agreed, with the caveat that these results are from mozilla-beta. If we get the same results on mozilla-central that's fine.

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

@staktrace Thanks for double checking those.

@pcwalton Looks like we need a try run against m-c, and to fix the rebase conflict above, then this should hopefully be good to go.

@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 5, 2018

@gw3583
Copy link
Contributor

gw3583 commented Dec 6, 2018

Try looks good (although will get @staktrace to double check again). Just need to resolve that conflicting png above then this is ready, I think.

@staktrace
Copy link
Contributor

Yup, try push looks good to me (I can adjust the reftest numbers on those two tests when I merge it to m-c).

@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 6, 2018

Patch updated.

@gw3583
Copy link
Contributor

gw3583 commented Dec 6, 2018

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 3b42369 has been approved by gw3583

@bors-servo
Copy link
Contributor

⌛ Testing commit 3b42369 with merge 013e808...

bors-servo pushed a commit that referenced this pull request Dec 6, 2018
Use the texture filtering hardware to reduce the number of sample operations in the blur shader.

Linear filtering allows us to evaluate the formula

    k₀c₀ + k₁c₁                 (Equation 1)

where c₀ and c₁ are the colors of adjacent texels and k₀ and k₁ are arbitrary
factors (in this case, the results of evaluating the Gaussian function) with a
single lookup. Linear filtering evaluates the following expression for some t
between 0 and 1:

    lerp(c₀, c₁, t)

It can be shown algebraically that Equation 1 is equivalent to:

                 ⎛           k₁  ⎞
    (k₀ + k₁)lerp⎜c₀, c₁, ───────⎟
                 ⎝        k₀ + k₁⎠

Which can be readily evaluated by letting `t = k₁/(k₀ + k₁)` and performing a
texture lookup.

This results in some minor visual differences because we always compute an even
number of pixels on each side (i.e. the *support* is now always rounded up to
the nearest even number of pixels), whereas before we might have evaluated an
odd number of pixels. All differences should therefore be minor quality
improvements.

Don't merge this yet; I want to run tests and a try build.

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

💔 Test failed - status-taskcluster

@gw3583
Copy link
Contributor

gw3583 commented Dec 6, 2018

One of the reftest fails on Linux CI and will need fuzziness of ..... 1 pixel .... max difference 1 🤦‍♂️

REFTEST TEST-UNEXPECTED-FAIL | reftests/text/two-shadows.yaml == reftests/text/two-shadows.png | image comparison, max difference: 1, number of differing pixels: 1

…rations in

the blur shader.

Linear filtering allows us to evaluate the formula

    k₀c₀ + k₁c₁                 (Formula 1)

where c₀ and c₁ are the colors of adjacent texels and k₀ and k₁ are arbitrary
factors (in this case, the results of evaluating the Gaussian function) with a
single lookup. Linear filtering evaluates the following expression for some t
between 0 and 1:

    lerp(c₀, c₁, t)

It can be shown algebraically that Formula 1 is equivalent to:

                 ⎛           k₁  ⎞
    (k₀ + k₁)lerp⎜c₀, c₁, ───────⎟
                 ⎝        k₀ + k₁⎠

Which can be readily evaluated by letting `t = k₁/(k₀ + k₁)` and performing a
texture lookup.
@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 6, 2018

Updated.

@staktrace
Copy link
Contributor

@bors-servo r=gw3583

@bors-servo
Copy link
Contributor

📌 Commit 38ec7db has been approved by gw3583

bors-servo pushed a commit that referenced this pull request Dec 6, 2018
Use the texture filtering hardware to reduce the number of sample operations in the blur shader.

Linear filtering allows us to evaluate the formula

    k₀c₀ + k₁c₁                 (Equation 1)

where c₀ and c₁ are the colors of adjacent texels and k₀ and k₁ are arbitrary
factors (in this case, the results of evaluating the Gaussian function) with a
single lookup. Linear filtering evaluates the following expression for some t
between 0 and 1:

    lerp(c₀, c₁, t)

It can be shown algebraically that Equation 1 is equivalent to:

                 ⎛           k₁  ⎞
    (k₀ + k₁)lerp⎜c₀, c₁, ───────⎟
                 ⎝        k₀ + k₁⎠

Which can be readily evaluated by letting `t = k₁/(k₀ + k₁)` and performing a
texture lookup.

This results in some minor visual differences because we always compute an even
number of pixels on each side (i.e. the *support* is now always rounded up to
the nearest even number of pixels), whereas before we might have evaluated an
odd number of pixels. All differences should therefore be minor quality
improvements.

Don't merge this yet; I want to run tests and a try build.

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

⌛ Testing commit 38ec7db with merge 19abc69...

@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: gw3583
Pushing 19abc69 to master...

@bors-servo bors-servo merged commit 38ec7db into servo:master Dec 6, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 7, 2018
…2b5ac5aeefe9 (WR PR #3122). r=kats

servo/webrender#3122

Differential Revision: https://phabricator.services.mozilla.com/D13975

--HG--
extra : moz-landing-system : lando
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Dec 8, 2018
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…2b5ac5aeefe9 (WR PR #3122). r=kats

servo/webrender#3122

Differential Revision: https://phabricator.services.mozilla.com/D13975

UltraBlame original commit: 2a526099b1f4405dd3df6852d38d0666580f4542
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…2b5ac5aeefe9 (WR PR #3122). r=kats

servo/webrender#3122

Differential Revision: https://phabricator.services.mozilla.com/D13975

UltraBlame original commit: 2a526099b1f4405dd3df6852d38d0666580f4542
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…2b5ac5aeefe9 (WR PR #3122). r=kats

servo/webrender#3122

Differential Revision: https://phabricator.services.mozilla.com/D13975

UltraBlame original commit: 2a526099b1f4405dd3df6852d38d0666580f4542
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.

None yet

6 participants