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

Elie Tournier tournier.elie at gmail.com
Wed Aug 23 11:08:03 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 dce0bf4a9f..7a5a30541f 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -74,6 +74,7 @@
 #define I2D                       (1U << 13)
 #define D2F                       (1U << 14)
 #define F2D                       (1U << 15)
+#define SQRT64                    (1U << 16)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 054cdcb50a..3681c4f0c5 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -487,6 +487,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_sqrt:
+      if (lowering(SQRT64)) {
+         if (ir->type->base_type == GLSL_TYPE_DOUBLE)
+            *rvalue = handle_op(ir, "__builtin_fsqrt64", generate_ir::fsqrt64);
+      }
+      break;
+
    case ir_unop_u2d:
       if (lowering(U2D)) {
          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 f26368812f..474e9bcdea 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7071,7 +7071,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                D2I |
                                I2D |
                                D2F |
-                               F2D;
+                               F2D |
+                               SQRT64;
          lower_64bit_double_instructions(ir, lower_inst);
       }
 
-- 
2.14.1



More information about the mesa-dev mailing list