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.
This commit is contained in:
Kenneth Graunke
2010-09-19 04:51:07 +02:00
parent 14eea26828
commit 6ea16b6c51

View File

@@ -623,36 +623,41 @@ ir_expression::constant_expression_value()
} }
break; break;
case ir_binop_equal: case ir_binop_equal:
switch (op[0]->type->base_type) { assert(op[0]->type == op[1]->type);
case GLSL_TYPE_UINT: for (unsigned c = 0; c < components; c++) {
data.b[0] = op[0]->value.u[0] == op[1]->value.u[0]; switch (op[0]->type->base_type) {
break; case GLSL_TYPE_UINT:
case GLSL_TYPE_INT: data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
data.b[0] = op[0]->value.i[0] == op[1]->value.i[0]; break;
break; case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT: data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
data.b[0] = op[0]->value.f[0] == op[1]->value.f[0]; break;
break; case GLSL_TYPE_FLOAT:
default: data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
assert(0); break;
default:
assert(0);
}
} }
break; break;
case ir_binop_nequal: case ir_binop_nequal:
switch (op[0]->type->base_type) { assert(op[0]->type != op[1]->type);
case GLSL_TYPE_UINT: for (unsigned c = 0; c < components; c++) {
data.b[0] = op[0]->value.u[0] != op[1]->value.u[0]; switch (op[0]->type->base_type) {
break; case GLSL_TYPE_UINT:
case GLSL_TYPE_INT: data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
data.b[0] = op[0]->value.i[0] != op[1]->value.i[0]; break;
break; case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT: data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
data.b[0] = op[0]->value.f[0] != op[1]->value.f[0]; break;
break; case GLSL_TYPE_FLOAT:
default: data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
assert(0); break;
default:
assert(0);
}
} }
break; break;
case ir_binop_all_equal: case ir_binop_all_equal:
data.b[0] = op[0]->has_value(op[1]); data.b[0] = op[0]->has_value(op[1]);
break; break;