glsl: Use constant_expression_value instead of as_constant
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 18 Jul 2014 23:10:16 +0000 (16:10 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 4 Aug 2014 21:40:06 +0000 (14:40 -0700)
Just a few lines earlier we may have wrapped the index expression with
ir_unop_i2u expression.  Whenever that happens, as_constant will return
NULL, and that almost always happens.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/lower_ubo_reference.cpp

index 67b752d3d22131d7245fd9e0dedd592abdd2bc8a..60094f13a1895cd29c72b4c287a5b47e01612059 100644 (file)
@@ -219,7 +219,8 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
          if (array_index->type->base_type == GLSL_TYPE_INT)
             array_index = i2u(array_index);
 
-        ir_constant *const_index = array_index->as_constant();
+        ir_constant *const_index =
+            array_index->constant_expression_value(NULL);
         if (const_index) {
            const_offset += array_stride * const_index->value.u[0];
         } else {