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

Elie Tournier tournier.elie at gmail.com
Wed Aug 23 11:08:05 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 3566673d30..4a44ee7660 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -76,6 +76,7 @@
 #define F2D                       (1U << 15)
 #define SQRT64                    (1U << 16)
 #define TRUNC64                   (1U << 17)
+#define ROUND64                   (1U << 18)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 0bbcfacf2a..894503a14f 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -478,6 +478,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_round_even:
+      if (lowering(ROUND64)) {
+         if (ir->type->base_type == GLSL_TYPE_DOUBLE)
+            *rvalue = handle_op(ir, "__builtin_fround64", generate_ir::fround64);
+      }
+      break;
+
    case ir_unop_sign:
       if (lowering(SIGN64)) {
          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 f746c5531a..760ffd594e 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7073,7 +7073,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                D2F |
                                F2D |
                                SQRT64 |
-                               TRUNC64;
+                               TRUNC64 |
+                               ROUND64;
          lower_64bit_double_instructions(ir, lower_inst);
       }
 
-- 
2.14.1



More information about the mesa-dev mailing list