glsl: support unsigned increment in ir_loop controls
authorTapani Pälli <tapani.palli@intel.com>
Wed, 30 Jul 2014 10:02:52 +0000 (13:02 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 7 Aug 2014 04:31:49 +0000 (07:31 +0300)
Current version can create ir_expression where operands have
different base type, patch adds support for unsigned type.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
https://bugs.freedesktop.org/show_bug.cgi?id=80880

src/glsl/loop_controls.cpp

index 36b49eb462e13b27fb3995e62d0951305303405f..1c1d34fefe64d18488fffa2e6704e8188f62a3a8 100644 (file)
@@ -123,9 +123,20 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
    bool valid_loop = false;
 
    for (unsigned i = 0; i < Elements(bias); i++) {
-      iter = (increment->type->is_integer())
-        ? new(mem_ctx) ir_constant(iter_value + bias[i])
-        : new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+      /* Increment may be of type int, uint or float. */
+      switch (increment->type->base_type) {
+      case GLSL_TYPE_INT:
+         iter = new(mem_ctx) ir_constant(iter_value + bias[i]);
+         break;
+      case GLSL_TYPE_UINT:
+         iter = new(mem_ctx) ir_constant(unsigned(iter_value + bias[i]));
+         break;
+      case GLSL_TYPE_FLOAT:
+         iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
+         break;
+      default:
+          unreachable(!"Unsupported type for loop iterator.");
+      }
 
       ir_expression *const mul =
         new(mem_ctx) ir_expression(ir_binop_mul, increment->type, iter,