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

Elie Tournier tournier.elie at gmail.com
Wed Aug 23 11:07:57 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 81ffe67077..aa71dfdb39 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -68,6 +68,7 @@
 #define LE64                      (1U << 7)
 #define LT64                      (1U << 8)
 #define ADD64                     (1U << 9)
+#define D2U                       (1U << 10)
 
 /**
  * \see class lower_packing_builtins_visitor
diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 9087cabda2..0b9d466b9d 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_d2u:
+      if (lowering(D2U)) {
+         if (ir->type->base_type == GLSL_TYPE_UINT)
+            *rvalue = handle_op(ir, "__builtin_fp64_to_uint", generate_ir::fp64_to_uint);
+      }
+      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 488d052336..de5a499f8d 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7065,7 +7065,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                LE64 |
                                LT64 |
                                ADD64 |
-                               MUL64;
+                               MUL64 |
+                               D2U;
          lower_64bit_double_instructions(ir, lower_inst);
       }
 
-- 
2.14.1



More information about the mesa-dev mailing list