diff options
| author | Kenneth Graunke <kenneth@whitecape.org> | 2010-09-19 04:51:07 +0200 | 
|---|---|---|
| committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-09-20 17:33:13 +0200 | 
| commit | 6ea16b6c510ee7f0e68505838a99562f0852f8e4 (patch) | |
| tree | f39cf9a7e3978532f165f34768e6b63a0a32e04e /src/glsl | |
| parent | 14eea268284491d64ff92b37723bff1e9ff14b40 (diff) | |
glsl: Fix broken handling of ir_binop_equal and ir_binop_nequal.
When ir_binop_all_equal and ir_binop_any_nequal were introduced, the
meaning of these two opcodes changed to return vectors rather than a
single scalar, but the constant expression handling code was incorrectly
written and only worked for scalars.  As a result, only the first
component of the returned vector would be properly initialized.
Diffstat (limited to 'src/glsl')
| -rw-r--r-- | src/glsl/ir_constant_expression.cpp | 55 | 
1 files changed, 30 insertions, 25 deletions
| diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index ec0e26de18..61a708f6e2 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -623,36 +623,41 @@ ir_expression::constant_expression_value()        }        break;     case ir_binop_equal: -      switch (op[0]->type->base_type) { -      case GLSL_TYPE_UINT: -         data.b[0] = op[0]->value.u[0] == op[1]->value.u[0]; -         break; -      case GLSL_TYPE_INT: -         data.b[0] = op[0]->value.i[0] == op[1]->value.i[0]; -         break; -      case GLSL_TYPE_FLOAT: -         data.b[0] = op[0]->value.f[0] == op[1]->value.f[0]; -         break; -      default: -         assert(0); +      assert(op[0]->type == op[1]->type); +      for (unsigned c = 0; c < components; c++) { +	 switch (op[0]->type->base_type) { +	 case GLSL_TYPE_UINT: +	    data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; +	    break; +	 case GLSL_TYPE_INT: +	    data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; +	    break; +	 case GLSL_TYPE_FLOAT: +	    data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; +	    break; +	 default: +	    assert(0); +	 }        }        break;     case ir_binop_nequal: -      switch (op[0]->type->base_type) { -      case GLSL_TYPE_UINT: -         data.b[0] = op[0]->value.u[0] != op[1]->value.u[0]; -         break; -      case GLSL_TYPE_INT: -         data.b[0] = op[0]->value.i[0] != op[1]->value.i[0]; -         break; -      case GLSL_TYPE_FLOAT: -         data.b[0] = op[0]->value.f[0] != op[1]->value.f[0]; -         break; -      default: -         assert(0); +      assert(op[0]->type != op[1]->type); +      for (unsigned c = 0; c < components; c++) { +	 switch (op[0]->type->base_type) { +	 case GLSL_TYPE_UINT: +	    data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; +	    break; +	 case GLSL_TYPE_INT: +	    data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; +	    break; +	 case GLSL_TYPE_FLOAT: +	    data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; +	    break; +	 default: +	    assert(0); +	 }        }        break; -     case ir_binop_all_equal:        data.b[0] = op[0]->has_value(op[1]);        break; | 
