|
d7b1ab58
|
2016-12-12T14:42:19
|
|
Fix up translator style.
Using git cl format.
BUG=angleproject:650
Change-Id: I7d3f98d2b0dcfb0a8de6c35327db74e55c28d761
Reviewed-on: https://chromium-review.googlesource.com/419059
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
|
2d73665d
|
2016-11-30T10:37:49
|
|
Handle constant folding arithmetic involving infinity
Constant folding arithmetic operations that involve infinity are now
handled correctly in the cases where the result is infinity or zero.
The implementation mostly relies on C++ to implement IEEE float
arithmetic correctly so that unnecessary overhead is avoided.
Constant folding arithmetic operations that result in overflow now
issue a warning but result in infinity. This is not mandated by the
spec but is a reasonable choice since it is the behavior of the
default IEEE rounding mode.
Constant folding arithmetic operations that result in NaN in IEEE will
generate a warning but the NaN is kept. This is also not mandated by
the spec, but is among the allowed behaviors.
There's no special handling for ESSL 1.00. ESSL 1.00 doesn't really
have the concept of NaN, but since it is not feasible to control
generating NaNs at shader run time either way, it should not be a big
issue if constant folding may generate them as well.
TEST=angle_unittests
BUG=chromium:661857
Change-Id: I06116c6fdd02f224939d4a651e4e62f2fd4c98a8
Reviewed-on: https://chromium-review.googlesource.com/414911
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
|
|
55644211
|
2016-11-08T11:07:34
|
|
Fix constant folding right shift corner cases
Right-shifting the minimum signed integer needs to be handled as a
special case, since it can't go through the usual path that clears the
sign bit.
Code for right-shifting by zero also had a typo that resulted in
setting the wrong value to the result.
BUG=chromium:662706
TEST=angle_unittests
Change-Id: Ief24d738064906a72212242e0917ce30e45d6b25
Reviewed-on: https://chromium-review.googlesource.com/408158
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
|
|
45bcc784
|
2016-11-07T13:58:48
|
|
translator: Scope all classes with "sh".
I was seeing an odd problem with our PoolAlloc conflicting with the
glslang/Vulkan TIntermNode, so the fix was to move everything to a
separate namespace.
The bison grammars are also regenerated. No functional changes.
BUG=angleproject:1576
Change-Id: I959c7afe4c092f0d458432c07b4dcee4d39513f3
Reviewed-on: https://chromium-review.googlesource.com/408267
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
|
4310354e
|
2016-10-10T12:28:13
|
|
Handle corner cases of shifting signed integers better
Right-shifting a negative number should sign-extend according to the
ESSL 3.00.6 spec. Implement sign-extending right shift so that it
doesn't hit any undefined behavior in the C++ spec. Negative lhs
operands are now allowed for bit-shift right.
Also implement bit-shift left via conversion to unsigned integer, so
that it does not hit signed integer overflow. Negative lhs operands
are now allowed also for bit-shift left as well.
BUG=chromium:654103
TEST=angle_unittests
Change-Id: Iee241de9fd0d74c2f8a88219bddec690bb8e4db2
Reviewed-on: https://chromium-review.googlesource.com/395688
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
|
|
7f9a55f7
|
2016-10-03T14:32:08
|
|
Fix integer math overflows in the preprocessor
Evaluating integer expressions in the ESSL preprocessor may result in
overflowing the signed integer range. Implement wrapping overflow for
preprocessor expressions in a way that doesn't hit any undefined
behavior. In the ESSL spec, preprocessor expressions are defined to
have mostly the same semantics as in C++. Since C++ doesn't define
what happens on signed integer overflow, we choose to make most of the
operators wrap on overflow for backward compatibility and consistency
with the rest of the ESSL spec.
We reuse the existing wrapping overflow helpers that are
used for constant folding. To be able to do this, the type used in the
preprocessor expression parser is changed from 64-bit to 32-bit.
Shifting negative numbers is implemented as a logical shift. This
cannot be disallowed since dEQP requires shaders shifting negative
numbers to pass compilation.
Undefined bitwise shifts where the offset is greater than 31 will now
result in a compile-time error.
A couple of test cases are now covered by the preprocessor tests
rather than full compilation tests. This isolates the tests better and
they run faster.
BUG=chromium:652223
TEST=angle_unittests
Change-Id: I84be40d404c10ecd0846c5d477e626a94a2a8587
Reviewed-on: https://chromium-review.googlesource.com/392146
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
|
|
1be4d493
|
2016-09-27T11:15:38
|
|
Fix handling integer overflow in constant folding
Integer operations that overflow are defined to wrap in the ESSL
3.00.6 spec. Constant folding that happens inside the shader
translator should also follow the wrapping rules.
The new implementations of wrapping integer addition and subtraction
use unsigned integers to perform calculations. Unsigned integers are
defined to implement arithmetic in modulo 2^n in the C++ spec. This
behavior is also leveraged to implement wrapping unsigned integer
multiplication.
The implementation of wrapping signed integer multiplication is
slightly trickier. The operands are casted to a wider type to perform
the multiplication in a way that doesn't overflow, and then the result
is truncated and casted back to the narrower integer type.
Incorrect tests that expected errors to be generated from integer
overflow in constant folding are removed.
BUG=chromium:637050
TEST=angle_unittests
Change-Id: I0de7e25881d254803455fbf22907c192f49d09ff
Reviewed-on: https://chromium-review.googlesource.com/390252
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
2cacb778
|
2016-09-26T08:50:40
|
|
Fix folding shifts when operands have different signedness
The code used to incorrectly assert that the right-hand side of shift
should have the same signedness as the left-hand side. Instead simply
assert that both the lhs and rhs are integer typed, and also don't
rely on aliasing via union when accessing bit shift operands.
Also disallow constant folded bit shifts where the right hand side is
greater than 31. Shifting with values greater than the width of the
type has undefined results in both ESSL and C++.
BUG=chromium:648135
TEST=angle_unittests
Change-Id: I84a99abc55f0eeda549b4781e954d17ba7b87552
Reviewed-on: https://chromium-review.googlesource.com/389351
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
|
|
44ebf6b4
|
2016-09-22T13:00:02
|
|
ConstantUnion: Error on undefined shift.
BUG=chromium:648135
Change-Id: I41581f63af650564a0f61c1baeeb38017c8513ed
Reviewed-on: https://chromium-review.googlesource.com/387470
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
596018ce
|
2016-09-21T12:57:03
|
|
translator: Refactor Constant Union shift ops.
In preparation for making them robust.
BUG=chromium:648135
Change-Id: I88fc87d8887064fda04087c56de05d8725a6fe5f
Reviewed-on: https://chromium-review.googlesource.com/387469
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
|
5db69f57
|
2016-09-15T12:47:32
|
|
Add robust math to constant folding.
Previously our multiplication and other operators could
do overflows, which can lead to security bugs.
BUG=chromium:637050
Change-Id: Icee22a87909e205b71bda1c5bc1627fcf5e26e90
Reviewed-on: https://chromium-review.googlesource.com/382678
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
47cb73ab
|
2016-09-09T11:41:44
|
|
Refactor TConstantUnion.
In preparation for constant folding fixes.
BUG=chromium:637050
Change-Id: I9ea49ce96b34c6ac3d2f0478b8fc6732c59e28be
Reviewed-on: https://chromium-review.googlesource.com/373741
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|