Commit 451ed25a by Yuly Novikov

Fix packSnorm2x16.

Casting -32767.0f to uint16_t on Android resulted in 0. According to C99 6.3.1.4 footnote 50 this kind of cast behavior is unspecified BUG=angleproject:913 TEST=build/android/test_runner.py gtest -s angle_unittests --release Change-Id: I136386fe0aa618c17f07f99d8e1ca72fa407d36a Reviewed-on: https://chromium-review.googlesource.com/323230 Tryjob-Request: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent a8e3494e
...@@ -585,9 +585,10 @@ struct IndexRange ...@@ -585,9 +585,10 @@ struct IndexRange
// packSnorm2x16 : round(clamp(c, -1, +1) * 32767.0) // packSnorm2x16 : round(clamp(c, -1, +1) * 32767.0)
inline uint32_t packSnorm2x16(float f1, float f2) inline uint32_t packSnorm2x16(float f1, float f2)
{ {
uint16_t leastSignificantBits = static_cast<uint16_t>(roundf(clamp(f1, -1.0f, 1.0f) * 32767.0f)); int16_t leastSignificantBits = static_cast<int16_t>(roundf(clamp(f1, -1.0f, 1.0f) * 32767.0f));
uint16_t mostSignificantBits = static_cast<uint16_t>(roundf(clamp(f2, -1.0f, 1.0f) * 32767.0f)); int16_t mostSignificantBits = static_cast<int16_t>(roundf(clamp(f2, -1.0f, 1.0f) * 32767.0f));
return static_cast<uint32_t>(mostSignificantBits) << 16 | static_cast<uint32_t>(leastSignificantBits); return static_cast<uint32_t>(mostSignificantBits) << 16 |
(static_cast<uint32_t>(leastSignificantBits) & 0xFFFF);
} }
// First, unpacks a single 32-bit unsigned integer u into a pair of 16-bit unsigned integers. Then, each // First, unpacks a single 32-bit unsigned integer u into a pair of 16-bit unsigned integers. Then, each
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment