New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 835868 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Email to this user bounced
Closed: Sep 14
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug

Blocked on:
issue angleproject:3064



Sign in to add a comment

GLSL bug: uvec(-1.) different if -1 as const or not

Reported by fabrice....@gmail.com, Apr 23 2018

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Example URL:
https://www.shadertoy.com/view/Ms3fz7

Steps to reproduce the problem:
display unsigned( -1. )
vs unsigned (uniform which value = -1. )
cf URL.

What is the expected behavior?
- same value
- i.e. 2^32 ( as for int->unsigned of constfloat -> unsigned )

What went wrong?
- different value
-  unsigned (     const -1. ) ) = 2^32
   unsigned ( not const -1. ) ) = 0

Note that for  -1 (integer) both give correct 2^32

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? No
 firefox

Chrome version: 65.0.3325.181  Channel: n/a
OS Version: 16.04
Flash Version: Shockwave Flash 29.0 r0

- tested wrong on linux/OpenGL and windows/Angle.
- the acid test in URL shows unsigned(-1.) is ok on const floats and wrong on unconst.
- if you switch the define, it shows that it's ok for int.

May somebody please set the flags	
Blink>WebGL
Internals>GPU
?  thanks !
 
NB: by "unsigned()" above I meant either uint() , uvec2(), uvec4(), uvec4().
Labels: Needs-Triage-M65
Components: -Blink Blink>WebGL
Cc: oetu...@nvidia.com
CC'ing Olli, who has a lot of experience with shader compiler issues.

Comment 5 by oetu...@nvidia.com, Apr 25 2018

Owner: oetu...@nvidia.com
Status: Started (was: Unconfirmed)
GLSL ES 3.00.6 section 5.4.1: "It is undefined to convert a negative floating point value to an uint". It's the same also in more recent versions.

That said it would be helpful to ensure that ANGLE is not using any undefined C++ behavior in its constant folding. Also we can issue a warning in case a negative float is being cast to unsigned int. Here's a patch:

https://chromium-review.googlesource.com/c/angle/angle/+/1026681
anyway there is a full load of operations where result differs totally between const float and unconst (and not just the precision).
This is ultra-dangerous since during and at the end of a project it's not rare to switch some parameters between const or not, and the effect might not show up immediately. 
I know the GLSL spec is just a big bag of holes, but maybe at least some constructors and Angle team might be interested in one upper-level of reliability ?  
( very seniored might all pile-up uint(int(floor(x))) to be safe, but how many unprotected lines of code around ?)
Project Member

Comment 7 by bugdroid1@chromium.org, Apr 25 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/f827123d99457a294c3d9451fe3af69772f0bcc2

commit f827123d99457a294c3d9451fe3af69772f0bcc2
Author: Olli Etuaho <oetuaho@nvidia.com>
Date: Wed Apr 25 14:21:03 2018

Handle negative float to uint conversion robustly

Converting a negative float to uint is undefined in the GLSL ES 3.00.6
spec.

However, it improves portability if we don't trigger undefined results
in C++ in this case. To do this, we cast negative floats first to
signed integer before casting them to unsigned integer.

We also issue a warning about an undefined conversion in case a
negative float was converted to uint.

BUG= chromium:835868 
TEST=angle_unittests

Change-Id: I9835a739ec80699d420a4f91a3bfa112c9a13604
Reviewed-on: https://chromium-review.googlesource.com/1026681
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>

[modify] https://crrev.com/f827123d99457a294c3d9451fe3af69772f0bcc2/src/tests/compiler_tests/ConstantFolding_test.cpp
[modify] https://crrev.com/f827123d99457a294c3d9451fe3af69772f0bcc2/src/compiler/translator/IntermNode.cpp
[modify] https://crrev.com/f827123d99457a294c3d9451fe3af69772f0bcc2/src/compiler/translator/ConstantUnion.cpp

Project Member

Comment 8 by bugdroid1@chromium.org, Apr 25 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d93a64651183f6f6117b442ea2aea74aab3e32cc

commit d93a64651183f6f6117b442ea2aea74aab3e32cc
Author: angle-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com <angle-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Date: Wed Apr 25 22:41:26 2018

Roll src/third_party/angle/ 10434f676..23dc90b81 (5 commits)

https://chromium.googlesource.com/angle/angle.git/+log/10434f67672d..23dc90b81efb

$ git log 10434f676..23dc90b81 --date=short --no-merges --format='%ad %ae %s'
2018-04-23 lfy GLES1: Enable/disable for texture targets
2018-04-25 oetuaho Handle negative float to uint conversion robustly
2018-04-24 lucferron Vulkan: Enable UnpackAlignmentTest and remove useless warning.
2018-04-24 lucferron Vulkan: Fix issue with texsubimage2d barriers
2018-04-25 jmadill Clean up DEPS style.

Created with:
  roll-dep src/third_party/angle
BUG= chromium:835868 , chromium:782846 


The AutoRoll server is located here: https://angle-chromium-roll.skia.org

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC'd on the roll, and stop the roller if necessary.


CQ_INCLUDE_TRYBOTS=luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
TBR=geofflang@chromium.org

Change-Id: I7ff0b0ad560ed9fadcce00db4c136232330826c9
Reviewed-on: https://chromium-review.googlesource.com/1028521
Commit-Queue: angle-chromium-autoroll <angle-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Reviewed-by: angle-chromium-autoroll <angle-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#553799}
[modify] https://crrev.com/d93a64651183f6f6117b442ea2aea74aab3e32cc/DEPS

Status: WontFix (was: Started)
There's not much more we can feasibly do to make this more consistent. Closing as WontFix since this case is not defined in the spec.

Comment 10 by kkinnu...@nvidia.com, Jan 21 (2 days ago)

Blockedon: angleproject:3064
Adding blocked on bug angleproject:3064, an alternative to defining the undefined behavior

Sign in to add a comment