Mesa (master): Revert "glsl: Fix constant-folding for reciprocal expressions"
Chad Versace
chadversary at kemper.freedesktop.org
Tue Feb 15 23:47:01 UTC 2011
Module: Mesa
Branch: master
Commit: f2e9981e43b26ca101b774ea6af1f00617098246
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2e9981e43b26ca101b774ea6af1f00617098246
Author: Chad Versace <chad.versace at intel.com>
Date: Mon Feb 14 11:16:42 2011 -0800
Revert "glsl: Fix constant-folding for reciprocal expressions"
This reverts commit b3cf92aa916ee0537ee37723c23a9897ac9cd3e0.
The reverted commit prevented constant-folding of reciprocal expressions
when the reciprocated expression was 0. However, since the spec allows
division by zero, constant-folding *is* permissible in this case.
>From Section 5.9 of the GLSL 1.20 spec:
Dividing by zero does not cause an exception but does result in an
unspecified value.
---
src/glsl/ir_constant_expression.cpp | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 2841fb3..7e00db6 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -288,24 +288,20 @@ ir_expression::constant_expression_value()
break;
case ir_unop_rcp:
- /* FINISHME: Emit warning when division-by-zero is detected. */
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
switch (this->type->base_type) {
case GLSL_TYPE_UINT:
- if (op[0]->value.u[c] == 0.0)
- return NULL;
- data.u[c] = 1 / op[0]->value.u[c];
+ if (op[0]->value.u[c] != 0.0)
+ data.u[c] = 1 / op[0]->value.u[c];
break;
case GLSL_TYPE_INT:
- if (op[0]->value.i[c] == 0.0)
- return NULL;
- data.i[c] = 1 / op[0]->value.i[c];
+ if (op[0]->value.i[c] != 0.0)
+ data.i[c] = 1 / op[0]->value.i[c];
break;
case GLSL_TYPE_FLOAT:
- if (op[0]->value.f[c] == 0.0)
- return NULL;
- data.f[c] = 1.0F / op[0]->value.f[c];
+ if (op[0]->value.f[c] != 0.0)
+ data.f[c] = 1.0F / op[0]->value.f[c];
break;
default:
assert(0);
More information about the mesa-commit
mailing list