Fix using representable texture channel ranges.
authorNicolas Capens <capn@google.com>
Mon, 8 Jan 2018 21:49:05 +0000 (16:49 -0500)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 23 Jan 2018 08:00:04 +0000 (03:00 -0500)
commita264a8e6cf86caef58bc3a62765f16e7c3e13d41
tree3a5bd7bc09d9f0349aa711f7b4d9146ee5fa390e
parent91f91b536ecdca5f49e2978f8cbc6b17d79675c6
Fix using representable texture channel ranges.

A value of 4294967295 (2^32 - 1) is not exactly representable in
IEEE-754 single-precision floating-point format, and so it gets rounded
to the next representable value, which is 4294967296. However, this
value can't be cast to an unsigned 32-bit integer without overflowing.

GLSL does not define what happens on overflow, and IEEE-754 defines it
as an exception but GLSL forbids exceptions. Hence some implementations
may produce unexpected results. dEQP assumed clamping to the largest
representable integer.

This change fixes that false assumption by reducing the range to values
representable in both float and integer formats.

Note that 32-bit integer formats can still hold values slightly larger
than these ranges. So while previously the floating-point ranges were
too large to represent integer values, they are now too small. This
can't be fixed without separating the integer format tests and only
using integer values to represent their ranges. This doesn't appear
necessary for the time being since the tests that use these floating-
point ranges have large 12/256 tolerances for the output color.

VK-GL-CTS issue: 937
Google bug: 70910885
Component: Framework

Change-Id: Ia2e8a187772bf37ed6ad35b13ed6f5071c46fb43
framework/common/tcuTextureUtil.cpp