[Mesa-dev] [PATCH 30/47] glsl: Add a lowering pass for 64-bit float i2d()

Elie Tournier tournier.elie at gmail.com
Wed Aug 23 11:08:00 UTC 2017


Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
---
 src/compiler/glsl/ir_optimization.h        | 1 +
 src/compiler/glsl/lower_64bit.cpp          | 7 +++++++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 157c7e1a6f..c59d7f6ee2 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -71,6 +71,7 @@
 #define D2U                       (1U << 10)
 #define U2D                       (1U << 11)
 #define D2I                       (1U << 12)
+#define I2D                       (1U << 13)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 41255094ec..570f997779 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -450,6 +450,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_i2d:
+      if (lowering(I2D)) {
+         if (ir->type->base_type == GLSL_TYPE_DOUBLE)
+            *rvalue = handle_op(ir, "__builtin_int_to_fp64", generate_ir::int_to_fp64, true);
+      }
+      break;
+
    case ir_unop_neg:
       if (lowering(NEG64)) {
          if (ir->type->base_type == GLSL_TYPE_DOUBLE)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 821461e439..1be223a3cb 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7068,7 +7068,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                MUL64 |
                                D2U |
                                U2D |
-                               D2I;
+                               D2I |
+                               I2D;
          lower_64bit_double_instructions(ir, lower_inst);
       }
 
-- 
2.14.1



More information about the mesa-dev mailing list