diff options
| author | Kenneth Graunke <kenneth@whitecape.org> | 2010-07-06 03:01:15 -0700 | 
|---|---|---|
| committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-07-06 16:03:33 -0700 | 
| commit | 37b3f9d0edb55807f822c02292348e20a8369c43 (patch) | |
| tree | 978e2884d66ca8b9cd799b70c3ecb54a3f239f5c /src | |
| parent | dad35eb8b0c7378588d9dca1c1091aaede83a83f (diff) | |
ir_constant_expression: Support scalar * vector and scalar * matrix.
The test here is slightly different since we need to keep matrix
multiplication separate.
Fixes piglit tests const-vec-scalar-03.frag and const-mat-scalar-03.frag.
Diffstat (limited to 'src')
| -rw-r--r-- | src/glsl/ir_constant_expression.cpp | 17 | 
1 files changed, 10 insertions, 7 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 2fab03bb60..e039504d4e 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -362,25 +362,28 @@ ir_constant_visitor::visit(ir_expression *ir)        break;     case ir_binop_mul: -      if (ir->operands[0]->type == ir->operands[1]->type && -	  !ir->operands[0]->type->is_matrix()) { -	 for (c = 0; c < ir->operands[0]->type->components(); c++) { +      if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix()) +	  || op0_scalar || op1_scalar) { +	 for (unsigned c = 0, c0 = 0, c1 = 0; +	      c < components; +	      c0 += c0_inc, c1 += c1_inc, c++) { +  	    switch (ir->operands[0]->type->base_type) {  	    case GLSL_TYPE_UINT: -	       data.u[c] = op[0]->value.u[c] * op[1]->value.u[c]; +	       data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1];  	       break;  	    case GLSL_TYPE_INT: -	       data.i[c] = op[0]->value.i[c] * op[1]->value.i[c]; +	       data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1];  	       break;  	    case GLSL_TYPE_FLOAT: -	       data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; +	       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. */ +	 /* FINISHME: Support vector/matrix and matrix multiplication. */  	 return;        break;  | 
