glsl: Implement constant expr evaluation for bitwise-not
authorChad Versace <chad@chad-versace.us>
Sat, 9 Oct 2010 00:28:34 +0000 (17:28 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 15 Oct 2010 07:20:18 +0000 (00:20 -0700)
Implement by adding a case to ir_expression::constant_expression_value()
for ir_unop_bit_not.

src/glsl/ir_constant_expression.cpp

index 8301e680278d52046695c85cef208c3d6c0875d0..4327175fc72c90374f3df3a07922b86b47b002d8 100644 (file)
@@ -100,6 +100,21 @@ ir_expression::constant_expression_value()
    }
 
    switch (this->operation) {
+   case ir_unop_bit_not:
+       switch (op[0]->type->base_type) {
+       case GLSL_TYPE_INT:
+           for (unsigned c = 0; c < components; c++)
+               data.i[c] = ~ op[0]->value.i[c];
+           break;
+       case GLSL_TYPE_UINT:
+           for (unsigned c = 0; c < components; c++)
+               data.u[c] = ~ op[0]->value.u[c];
+           break;
+       default:
+           assert(0);
+       }
+       break;
+
    case ir_unop_logic_not:
       assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
       for (unsigned c = 0; c < op[0]->type->components(); c++)