[Mesa-dev] [PATCH 11/23] glsl/ast: add 64-bit integer support to conversion functions

Dave Airlie airlied at gmail.com
Thu Jun 9 00:48:12 UTC 2016


From: Dave Airlie <airlied at redhat.com>

This adds support to call the new operations on conversions.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/compiler/glsl/ast_function.cpp | 75 ++++++++++++++++++++++++++++++++++++++
 src/compiler/glsl/ast_to_hir.cpp   | 20 ++++++++++
 2 files changed, 95 insertions(+)

diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index f74394f..399a142 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -757,6 +757,12 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_DOUBLE:
 	 result = new(ctx) ir_expression(ir_unop_d2u, src);
 	 break;
+      case GLSL_TYPE_UINT64:
+	 result = new(ctx) ir_expression(ir_unop_u642u, src);
+	 break;
+      case GLSL_TYPE_INT64:
+	 result = new(ctx) ir_expression(ir_unop_i642u, src);
+	 break;
       }
       break;
    case GLSL_TYPE_INT:
@@ -773,6 +779,12 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_DOUBLE:
 	 result = new(ctx) ir_expression(ir_unop_d2i, src);
 	 break;
+      case GLSL_TYPE_UINT64:
+	 result = new(ctx) ir_expression(ir_unop_u642i, src);
+	 break;
+      case GLSL_TYPE_INT64:
+	 result = new(ctx) ir_expression(ir_unop_i642i, src);
+	 break;
       }
       break;
    case GLSL_TYPE_FLOAT:
@@ -789,6 +801,12 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_DOUBLE:
 	 result = new(ctx) ir_expression(ir_unop_d2f, desired_type, src, NULL);
 	 break;
+      case GLSL_TYPE_UINT64:
+	 result = new(ctx) ir_expression(ir_unop_u642f, desired_type, src, NULL);
+	 break;
+      case GLSL_TYPE_INT64:
+	 result = new(ctx) ir_expression(ir_unop_i642f, desired_type, src, NULL);
+	 break;
       }
       break;
    case GLSL_TYPE_BOOL:
@@ -806,6 +824,12 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_DOUBLE:
          result = new(ctx) ir_expression(ir_unop_d2b, desired_type, src, NULL);
          break;
+      case GLSL_TYPE_UINT64:
+	 result = new(ctx) ir_expression(ir_unop_u642b, desired_type, src, NULL);
+	 break;
+      case GLSL_TYPE_INT64:
+	 result = new(ctx) ir_expression(ir_unop_i642b, desired_type, src, NULL);
+	 break;
       }
       break;
    case GLSL_TYPE_DOUBLE:
@@ -823,7 +847,58 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_FLOAT:
          result = new(ctx) ir_expression(ir_unop_f2d, desired_type, src, NULL);
          break;
+      case GLSL_TYPE_UINT64:
+	 result = new(ctx) ir_expression(ir_unop_u642d, desired_type, src, NULL);
+	 break;
+      case GLSL_TYPE_INT64:
+	 result = new(ctx) ir_expression(ir_unop_i642d, desired_type, src, NULL);
+	 break;
       }
+      break;
+   case GLSL_TYPE_UINT64:
+      switch (b) {
+      case GLSL_TYPE_INT:
+         result = new(ctx) ir_expression(ir_unop_i2u64, src);
+         break;
+      case GLSL_TYPE_UINT:
+         result = new(ctx) ir_expression(ir_unop_u2u64, src);
+         break;
+      case GLSL_TYPE_BOOL:
+         result = new(ctx) ir_expression(ir_unop_b2u64, src);
+         break;
+      case GLSL_TYPE_FLOAT:
+         result = new(ctx) ir_expression(ir_unop_f2u64, src);
+         break;
+      case GLSL_TYPE_DOUBLE:
+         result = new(ctx) ir_expression(ir_unop_d2u64, src);
+         break;
+      case GLSL_TYPE_INT64:
+         result = new(ctx) ir_expression(ir_unop_i642u64, src);
+         break;
+      }
+      break;
+   case GLSL_TYPE_INT64:
+      switch (b) {
+      case GLSL_TYPE_INT:
+         result = new(ctx) ir_expression(ir_unop_i2i64, src);
+         break;
+      case GLSL_TYPE_UINT:
+         result = new(ctx) ir_expression(ir_unop_u2i64, src);
+         break;
+      case GLSL_TYPE_BOOL:
+         result = new(ctx) ir_expression(ir_unop_b2i64, src);
+         break;
+      case GLSL_TYPE_FLOAT:
+         result = new(ctx) ir_expression(ir_unop_f2i64, src);
+         break;
+      case GLSL_TYPE_DOUBLE:
+         result = new(ctx) ir_expression(ir_unop_d2i64, src);
+         break;
+      case GLSL_TYPE_UINT64:
+         result = new(ctx) ir_expression(ir_unop_u642i64, src);
+         break;
+      }
+      break;
    }
 
    assert(result != NULL);
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 0cf0941..abcd491 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -258,8 +258,28 @@ get_implicit_conversion_operation(const glsl_type *to, const glsl_type *from,
       case GLSL_TYPE_INT: return ir_unop_i2d;
       case GLSL_TYPE_UINT: return ir_unop_u2d;
       case GLSL_TYPE_FLOAT: return ir_unop_f2d;
+      case GLSL_TYPE_INT64: return ir_unop_i642d;
+      case GLSL_TYPE_UINT64: return ir_unop_u642d;
       default: return (ir_expression_operation)0;
       }
+   case GLSL_TYPE_UINT64:
+      if (!state->has_int64())
+         return (ir_expression_operation)0;
+      switch (from->base_type) {
+      case GLSL_TYPE_INT: return ir_unop_i2u64;
+      case GLSL_TYPE_UINT: return ir_unop_u2u64;
+      case GLSL_TYPE_INT64: return ir_unop_i642u64;
+      default: return (ir_expression_operation)0;
+      }
+
+   case GLSL_TYPE_INT64:
+      if (!state->has_int64())
+         return (ir_expression_operation)0;
+      switch (from->base_type) {
+      case GLSL_TYPE_INT: return ir_unop_i2i64;
+      default: return (ir_expression_operation)0;
+      }
+      break;
 
    default: return (ir_expression_operation)0;
    }
-- 
2.5.5



More information about the mesa-dev mailing list