ir_constant_expression: Support scalar - vector and scalar - matrix.

Fixes piglit tests const-vec-scalar-02.frag and const-mat-scalar-02.frag.
This commit is contained in:
Kenneth Graunke
2010-07-06 02:53:29 -07:00
committed by Ian Romanick
parent e74dcd7924
commit 97b44f040a

View File

@@ -340,25 +340,25 @@ ir_constant_visitor::visit(ir_expression *ir)
break; break;
case ir_binop_sub: case ir_binop_sub:
if (ir->operands[0]->type == ir->operands[1]->type) { assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (c = 0; c < ir->operands[0]->type->components(); c++) { for (unsigned c = 0, c0 = 0, c1 = 0;
switch (ir->operands[0]->type->base_type) { c < components;
case GLSL_TYPE_UINT: c0 += c0_inc, c1 += c1_inc, c++) {
data.u[c] = op[0]->value.u[c] - op[1]->value.u[c];
break; switch (ir->operands[0]->type->base_type) {
case GLSL_TYPE_INT: case GLSL_TYPE_UINT:
data.i[c] = op[0]->value.i[c] - op[1]->value.i[c]; data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1];
break; break;
case GLSL_TYPE_FLOAT: case GLSL_TYPE_INT:
data.f[c] = op[0]->value.f[c] - op[1]->value.f[c]; data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1];
break; break;
default: case GLSL_TYPE_FLOAT:
assert(0); data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1];
} break;
default:
assert(0);
} }
} else }
/* FINISHME: Support operations with non-equal types. */
return;
break; break;
case ir_binop_mul: case ir_binop_mul: