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

Elie Tournier tournier.elie at gmail.com
Wed Aug 23 11:07:50 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 6cc0909a80..ad76a7032e 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -63,6 +63,7 @@
 #define DIV64                     (1U << 2)
 #define MOD64                     (1U << 3)
 #define ABS64                     (1U << 4)
+#define NEG64                     (1U << 5)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 4887e5538c..91b972fe82 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -412,6 +412,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_neg:
+      if (lowering(NEG64)) {
+         if (ir->type->base_type == GLSL_TYPE_DOUBLE)
+            *rvalue = handle_op(ir, "__builtin_fneg64", generate_ir::fneg64);
+      }
+      break;
+
    case ir_unop_sign:
       if (lowering(SIGN64)) {
          *rvalue = handle_op(ir, "__builtin_sign64", generate_ir::sign64);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 991eae4917..3b0b19be53 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7058,7 +7058,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
        */
       if (!pscreen->get_param(pscreen, PIPE_CAP_DOUBLES) &&
             ctx->Const.GLSLVersion >= 130) {
-         unsigned lower_inst = ABS64;
+         unsigned lower_inst = ABS64 |
+                               NEG64;
          lower_64bit_double_instructions(ir, lower_inst);
       }
 
-- 
2.14.1



More information about the mesa-dev mailing list