diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2013-01-16 19:49:40 -0800 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2013-01-24 21:24:07 -0800 |
commit | eac030e38e3cdd4ed4534516e3d3a50c8a372719 (patch) | |
tree | 29b81f500914cd9371e10625809f4286048b6a96 /src/glsl/ir_constant_expression.cpp | |
parent | 1fafd008392d5240dc36d0c72978cef62e21b4b1 (diff) | |
download | external_mesa3d-eac030e38e3cdd4ed4534516e3d3a50c8a372719.zip external_mesa3d-eac030e38e3cdd4ed4534516e3d3a50c8a372719.tar.gz external_mesa3d-eac030e38e3cdd4ed4534516e3d3a50c8a372719.tar.bz2 |
mesa,glsl: Move round_to_even() from glsl to mesa/main (v2)
Move round_to_even's definition to mesa/main so that _mesa_float_to_half()
can use it in order to eliminate rounding bias.
In additon to moving the fuction definition, prefix its name with "_mesa",
just as all other functions in mesa/main are prefixed.
v2: Fix Android build.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r-- | src/glsl/ir_constant_expression.cpp | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 17b54b9..7678090 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -40,25 +40,6 @@ #include "glsl_types.h" #include "program/hash_table.h" -/* Using C99 rounding functions for roundToEven() implementation is - * difficult, because round(), rint, and nearbyint() are affected by - * fesetenv(), which the application may have done for its own - * purposes. Mesa's IROUND macro is close to what we want, but it - * rounds away from 0 on n + 0.5. - */ -static int -round_to_even(float val) -{ - int rounded = IROUND(val); - - if (val - floor(val) == 0.5) { - if (rounded % 2 != 0) - rounded += val > 0 ? -1 : 1; - } - - return rounded; -} - static float dot(ir_constant *op0, ir_constant *op1) { @@ -279,7 +260,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) case ir_unop_round_even: assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = round_to_even(op[0]->value.f[c]); + data.f[c] = _mesa_round_to_even(op[0]->value.f[c]); } break; |