[Mesa-dev] [PATCH 38/47] glsl/lower_64bit: lower d2b using comparison

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


From: Dave Airlie <airlied at redhat.com>

This just does a compare to 0 and inverts the result to lower
d2b. Not 100% sure this is always correct, but it passes piglit
---
 src/compiler/glsl/lower_64bit.cpp | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/lower_64bit.cpp b/src/compiler/glsl/lower_64bit.cpp
index 79148bb169..4978759eb9 100644
--- a/src/compiler/glsl/lower_64bit.cpp
+++ b/src/compiler/glsl/lower_64bit.cpp
@@ -361,7 +361,7 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
                                        ir_expression *ir,
                                        ir_function_signature *callee)
 {
-   const unsigned num_operands = ir->num_operands;
+   unsigned num_operands = ir->num_operands;
    ir_variable *src[4][4];
    ir_variable *dst[4];
    void *const mem_ctx = ralloc_parent(ir);
@@ -390,6 +390,16 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
          source_components = ir->operands[i]->type->vector_elements;
    }
 
+   if (ir->operation == ir_unop_d2b) {
+      for (unsigned i = 0; i < source_components; i++) {
+         src[1][i] = body.make_temp(glsl_type::uvec2_type, "zero");
+
+         body.emit(assign(src[1][i], body.constant(0u), 1));
+         body.emit(assign(src[1][i], body.constant(0u), 2));
+      }
+      num_operands++;
+   }
+
    for (unsigned i = 0; i < source_components; i++) {
       dst[i] = body.make_temp(result_type, "expanded_64bit_result");
 
@@ -406,6 +416,9 @@ lower_64bit::lower_op_to_function_call(ir_instruction *base_ir,
                                               &parameters);
 
       body.emit(c);
+
+      if (ir->operation == ir_unop_d2b)
+         body.emit(assign(dst[i], logic_not(dst[i])));
    }
 
    ir_rvalue *rv;
@@ -487,6 +500,13 @@ lower_64bit_visitor::handle_rvalue(ir_rvalue **rvalue)
       }
       break;
 
+   case ir_unop_d2b:
+      if (lowering(EQ64)) {
+         if (ir->type->base_type == GLSL_TYPE_BOOL)
+            *rvalue = handle_op(ir, "__builtin_feq64", generate_ir::feq64);
+      }
+      break;
+
    case ir_unop_d2f:
       if (lowering(D2F)) {
          if (ir->type->base_type == GLSL_TYPE_FLOAT)
-- 
2.14.1



More information about the mesa-dev mailing list