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

Modify the webgl line feature shaders. #816

Merged
merged 2 commits into from
May 15, 2018
Merged

Conversation

manthey
Copy link
Contributor

@manthey manthey commented May 9, 2018

Chrome 65 and 66 when running in xvfb with openmesa do not compute atan(0, <negative>) correctly. Also, there are occasional int() casts that round down even when they are small integers. These changes make image comparisons more robust by working around the atan issue (this may be the issue detailed in https://chromium.googlesource.com/angle/angle/commit/da9fb09). I have submitted a new issue to chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=841296 to track this problem.

With this commit, the baselines were regenerated with Chrome 64, and the test strictness requirements changed in PR #792 have been reverted. There are subtly differences between Chrome 64 and 66 (font aliasing is slightly different, and I think the other changes are because the shader float precision is subtly different, though I'm not sure of that).

@manthey manthey force-pushed the image-test-stability branch from 501d4ff to ccf954d Compare May 11, 2018 14:25
@manthey
Copy link
Contributor Author

manthey commented May 11, 2018

Curiously, atan has issues both on Google's swiftshader and on osmesa (Mesa 17.2.8). This changes works around the problem on both of them.

manthey added 2 commits May 11, 2018 15:07
Chrome 65 and 66 when running in xvfb with openmesa do not compute
atan(0, <negative>) correctly.  Also, there are occasional int() casts
that round down even when they are small integers.  These changes make
image comparisons more robust by working around the atan issue (this may
be the issue detailed in
chromium.googlesource.com/angle/angle/commit/da9fb09).  I have submitted
a new issue to chromium:
https://bugs.chromium.org/p/chromium/issues/detail?id=841296 to track
this problem.

With this commit, the baselines were regenerated with Chrome 64, and the
test strictness requirements changed in PR #792 have been reverted.
There are subtly differences between Chrome 64 and 66 (font aliasing is
slightly different, and I think the other changes are because the shader
float precision is subtly different, though I'm not sure of that).
@manthey manthey force-pushed the image-test-stability branch from ccf954d to 682fa56 Compare May 11, 2018 19:07
@@ -275,8 +286,8 @@ var gl_lineFeature = function (arg) {
' vec4 color = strokeColorVar;',
allowDebug ? ' bool debug = bool(mod(fixedFlags, 2.0));' : '',
' float opacity = 1.0;',
' int nearMode = int(info.x);',
' int farMode = int(info.y);',
' int nearMode = int(floor(info.x + 0.5));',
Copy link
Member

Choose a reason for hiding this comment

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

why extra 0.5?

Copy link
Member

@aashish24 aashish24 May 15, 2018

Choose a reason for hiding this comment

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

is it because info.x is slightly less?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We really want to use a round function, but WebGL doesn't have one. In the osmesa implementation, this is sometimes very slightly less than the integer we start with (2.999999 versus 3), so a very tiny addition would be sufficient, but a general round function is often floor(value + 0.5), so I've used that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although the vertex shader produces consistent values (info.x at the three vertices will have an identical integer value in the range of [0-7]), this somehow is not always an exact integer in the fragment shader. I don't know what osmesa does that causes this (the various actual GPUs that execute this seem to always have the exact integer), but this works around the issue.

Copy link
Member

Choose a reason for hiding this comment

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

got it.

@manthey manthey merged commit 4879f75 into master May 15, 2018
@manthey manthey deleted the image-test-stability branch May 15, 2018 14:50
@aashish24
Copy link
Member

one thing i noted " shader float precision is subtly different" can you elaborate? We could ask for particular precision in the shader code.

@manthey
Copy link
Contributor Author

manthey commented May 15, 2018

You can ask for three precisions - lowp, mediump, and highp. In the fragment shader, the implementation does not have to allow highp. The spec states that these need to have at least 8, 10, and 16 bits of mantissa each (and also specifies minimum exponent range as well). But these are minimums -- so if one implementation of mediump provides 10 bits, but a change provides 11, that would be allowed, but would result in differences. My AMD card, for instance, provides 23 bits regardless of the level requested. swiftshader appears to have changed what it provides recently, but I haven't dug through its change log or source code enough to determine the change.

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.

2 participants