mesa/src/util
Kenneth Graunke 2412c4c81e util: Make CLAMP turn NaN into MIN.
The previous implementation of CLAMP() allowed NaN to pass through
unscathed, by failing both comparisons.  NaN isn't exactly a value
between MIN and MAX, which can break the assumptions of many callers.

This patch changes CLAMP to convert NaN to MIN, arbitrarily.  Callers
that need NaN to be handled in a specific manner should probably open
code something, or use a macro specifically designed to do that.

Section 2.3.4.1 of the OpenGL 4.5 spec says:

   "Any representable floating-point value is legal as input to a GL
    command that requires floating-point data. The result of providing a
    value that is not a floating-point number to such a command is
    unspecified, but must not lead to GL interruption or termination.
    In IEEE arithmetic, for example, providing a negative zero or a
    denormalized number to a GL command yields predictable results,
    while providing a NaN or an infinity yields unspecified results."

While CLAMP may apply to more than just GL inputs, it seems reasonable
to follow those rules, and allow MIN as an "unspecified result".

This prevents assertion failures in i965 when running the games
"XCOM: Enemy Unknown" and "XCOM: Enemy Within", which call

   glTexEnv(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
            -nan(0x7ffff3));

presumably unintentionally.  i965 clamps the LOD bias to be in range,
and asserts that it's in the proper range when converting to fixed
point.  NaN is not, so it crashed.  We'd like to at least avoid that.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2017-07-18 23:48:46 -07:00
..
sha1
tests/hash_table
.gitignore
Android.mk
bitscan.c
bitscan.h gallium: use "ull" number suffix to keep the QtCreator parser happy 2017-07-10 22:44:48 +02:00
bitset.h
build_id.c
build_id.h
crc32.c
crc32.h
debug.c
debug.h
disk_cache.c util/u_queue: add an option to set the minimum thread priority 2017-06-07 18:43:42 +02:00
disk_cache.h util/disk_cache: fix a comment 2017-07-03 13:57:01 +02:00
format_r11g11b10f.h
format_rgb9e5.h
format_srgb.h
format_srgb.py
half_float.c
half_float.h
hash_table.c mesa/util: add a hash table wrapper which support 64-bit keys 2017-06-14 10:04:35 +02:00
hash_table.h mesa/util: add a hash table wrapper which support 64-bit keys 2017-06-14 10:04:35 +02:00
list.h
macros.h util: Make CLAMP turn NaN into MIN. 2017-07-18 23:48:46 -07:00
Makefile.am
Makefile.sources util: Move u_dynarray to src/util 2017-06-07 21:07:24 +02:00
mesa-sha1.c
mesa-sha1.h
ralloc.c util: remove unneeded Android ifdef from ralloc.c 2017-05-25 15:02:12 -05:00
ralloc.h
rand_xor.c util/rand_xor: add missing include statements 2017-06-01 14:26:12 +01:00
rand_xor.h
register_allocate.c
register_allocate.h
rgtc.c
rgtc.h
roundeven_test.c
rounding.h
SConscript
set.c util: make set's deleted_key_value declaration consistent with hash table one 2017-06-08 09:26:44 +02:00
set.h
simple_list.h
slab.c util: slab_destroy_child should check whether it's been initialized 2017-05-29 01:52:16 +02:00
slab.h
string_to_uint_map.cpp
string_to_uint_map.h
strndup.h
strtod.c
strtod.h
texcompress_rgtc_tmp.h
u_atomic.c
u_atomic.h
u_atomic_test.c
u_dynarray.h mesa/util: add util_dynarray_clear() helper 2017-06-18 14:10:32 +02:00
u_endian.h
u_queue.c util/u_queue: add an option to resize the queue when it's full 2017-07-17 10:57:20 -04:00
u_queue.h util/u_queue: add an option to resize the queue when it's full 2017-07-17 10:57:20 -04:00
u_string.h
u_thread.h util: move pipe_thread_is_self from gallium to src/util 2017-06-26 02:17:03 +02:00
u_vector.c util: Remove u_math from u_vector 2017-07-14 14:14:05 +01:00
u_vector.h util: Remove u_math from u_vector 2017-07-14 14:14:05 +01:00