[Mesa-dev] [PATCH 15/20] glsl: support double increment in ir_loop controls

Dave Airlie airlied at gmail.com
Wed Sep 3 21:15:37 PDT 2014


From: Tapani Pälli <tapani.palli at intel.com>

Patch makes following Piglit test pass:
   arb_gpu_shader_fp64/compiler/double-loop-iterator.vert

v2: make also sure that calculate_iterations handles
    double correctly, now the test *really* passes

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/glsl/loop_controls.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 1c1d34f..9a99c21 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -102,10 +102,18 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
       return -1;
 
    if (!iter->type->is_integer()) {
-      ir_rvalue *cast =
-	 new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter,
-				    NULL);
-
+      ir_rvalue *cast = NULL;
+      if (iter->type->is_double()) {
+         ir_expression *d2f =
+            new(mem_ctx) ir_expression(ir_unop_d2f, glsl_type::float_type,
+                                       iter, NULL);
+         cast = new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type,
+                                           (ir_rvalue*) d2f, NULL);
+      } else {
+         cast = new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter,
+                                           NULL);
+      }
+      assert(cast);
       iter = cast->constant_expression_value();
    }
 
@@ -134,6 +142,9 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
       case GLSL_TYPE_FLOAT:
          iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
          break;
+      case GLSL_TYPE_DOUBLE:
+         iter = new(mem_ctx) ir_constant(double(iter_value + bias[i]));
+         break;
       default:
           unreachable(!"Unsupported type for loop iterator.");
       }
-- 
2.1.0



More information about the mesa-dev mailing list