diff options
author | Chad Versace <[email protected]> | 2010-10-09 21:27:41 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2010-10-15 00:20:18 -0700 |
commit | 4761d0d22ba79fa34adf679007498287e9fedca2 (patch) | |
tree | e16a65a188bc562c89a99c10d213f970a4cbbbe2 /src/glsl/ir_constant_expression.cpp | |
parent | adea8150a70f975c31c68f3e84ec3f8b0b448cf0 (diff) |
glsl: Implement constant expr evaluation for bitwise logic ops
Implement by adding the following cases to
ir_exporession::constant_expression_value():
- ir_binop_bit_and
- ir_binop_bit_or
- ir_binop_bit_xor
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r-- | src/glsl/ir_constant_expression.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index b250a164a1a..048c020c835 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -728,6 +728,60 @@ ir_expression::constant_expression_value() } break; + case ir_binop_bit_and: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] & op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] & op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + + case ir_binop_bit_or: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] | op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] | op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + + case ir_binop_bit_xor: + for (unsigned c = 0, c0 = 0, c1 = 0; + c < components; + c0 += c0_inc, c1 += c1_inc, c++) { + + switch (op[0]->type->base_type) { + case GLSL_TYPE_INT: + data.i[c] = op[0]->value.i[c0] ^ op[1]->value.i[c1]; + break; + case GLSL_TYPE_UINT: + data.u[c] = op[0]->value.u[c0] ^ op[1]->value.u[c1]; + break; + default: + assert(0); + } + } + break; + default: /* FINISHME: Should handle all expression types. */ return NULL; |