Mesa (master): glsl: Implement constant expr evaluation for bitwise-not

Kenneth Graunke kwg at kemper.freedesktop.org
Fri Oct 15 07:20:50 UTC 2010


Module: Mesa
Branch: master
Commit: 90a8b792c04679fc745e5a68ead9f7c37b8d07c4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=90a8b792c04679fc745e5a68ead9f7c37b8d07c4

Author: Chad Versace <chad at chad-versace.us>
Date:   Fri Oct  8 17:28:34 2010 -0700

glsl: Implement constant expr evaluation for bitwise-not

Implement by adding a case to ir_expression::constant_expression_value()
for ir_unop_bit_not.

---

 src/glsl/ir_constant_expression.cpp |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 8301e68..4327175 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -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++)




More information about the mesa-commit mailing list