[Mesa-dev] [PATCH 10/27] glsl: add 64-bit integer support for constant expressions (v2)

Ian Romanick idr at freedesktop.org
Wed Jun 29 23:33:41 UTC 2016


On 06/19/2016 10:06 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This just adds the new operations and add 64-bit integer
> support to all the existing cases where it is needed.
> 
> v2: fix some issues found in testing.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/glsl/ir_constant_expression.cpp | 428 ++++++++++++++++++++++++---
>  1 file changed, 391 insertions(+), 37 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp
> index d961aa9..7daf644 100644
> --- a/src/compiler/glsl/ir_constant_expression.cpp
> +++ b/src/compiler/glsl/ir_constant_expression.cpp
> @@ -88,6 +88,42 @@ bitcast_f2u(float f)
>     return u;
>  }
>  
> +static double
> +bitcast_u642d(uint64_t u)
> +{
> +   assert(sizeof(double) == sizeof(uint64_t));
> +   double d;
> +   memcpy(&d, &u, sizeof(d));
> +   return d;
> +}
> +
> +static double
> +bitcast_i642d(int64_t i)
> +{
> +   assert(sizeof(double) == sizeof(int64_t));
> +   double d;
> +   memcpy(&d, &i, sizeof(d));
> +   return d;
> +}
> +
> +static double
> +bitcast_d2u64(double d)
> +{
> +   assert(sizeof(double) == sizeof(uint64_t));
> +   uint64_t u;
> +   memcpy(&u, &d, sizeof(d));
> +   return u;
> +}
> +
> +static double
> +bitcast_d2i64(double d)
> +{
> +   assert(sizeof(double) == sizeof(int64_t));
> +   int64_t i;
> +   memcpy(&i, &d, sizeof(d));
> +   return i;
> +}
> +
>  /**
>   * Evaluate one component of a floating-point 4x8 unpacking function.
>   */
> @@ -690,6 +726,162 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           data.b[c] = op[0]->value.d[c] != 0.0;
>        }
>        break;
> +   case ir_unop_bitcast_u642d:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.d[c] = bitcast_u642d(op[0]->value.u64[c]);
> +      }
> +      break;
> +   case ir_unop_bitcast_i642d:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.d[c] = bitcast_i642d(op[0]->value.i64[c]);
> +      }
> +      break;
> +   case ir_unop_bitcast_d2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = bitcast_d2u64(op[0]->value.d[c]);
> +      }
> +      break;
> +   case ir_unop_bitcast_d2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = bitcast_d2i64(op[0]->value.d[c]);
> +      }
> +      break;
> +   case ir_unop_i642i:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i[c] = op[0]->value.i64[c];
> +      }
> +      break;
> +   case ir_unop_u642i:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i[c] = op[0]->value.u64[c];
> +      }
> +      break;
> +   case ir_unop_i642u:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u[c] = op[0]->value.i64[c];
> +      }
> +      break;
> +   case ir_unop_u642u:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u[c] = op[0]->value.u64[c];
> +      }
> +      break;
> +   case ir_unop_i642b:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.b[c] = op[0]->value.i64[c] != 0;
> +      }
> +      break;
> +   case ir_unop_u642b:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.b[c] = op[0]->value.u64[c] != 0;
> +      }
> +      break;
> +   case ir_unop_i642f:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.f[c] = op[0]->value.i64[c];
> +      }
> +      break;
> +   case ir_unop_u642f:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.f[c] = op[0]->value.u64[c];
> +      }
> +      break;
> +   case ir_unop_i642d:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.d[c] = op[0]->value.i64[c];
> +      }
> +      break;
> +   case ir_unop_u642d:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.d[c] = op[0]->value.u64[c];
> +      }
> +      break;
> +   case ir_unop_i2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.i[c];
> +      }
> +      break;
> +   case ir_unop_u2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.u[c];
> +      }
> +      break;
> +   case ir_unop_b2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.b[c];
> +      }
> +      break;
> +   case ir_unop_f2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.f[c];
> +      }
> +      break;
> +   case ir_unop_d2i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.d[c];
> +      }
> +      break;
> +   case ir_unop_i2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.i[c];
> +      }
> +      break;
> +   case ir_unop_u2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = op[0]->value.u[c];
> +      }
> +      break;
> +   case ir_unop_b2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = op[0]->value.b[c];
> +      }
> +      break;
> +   case ir_unop_f2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = op[0]->value.f[c];
> +      }
> +      break;
> +   case ir_unop_d2u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = op[0]->value.d[c];
> +      }
> +      break;
> +   case ir_unop_i642u64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_INT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.u64[c] = op[0]->value.i64[c];
> +      }
> +      break;
> +   case ir_unop_u642i64:
> +      assert(op[0]->type->base_type == GLSL_TYPE_UINT64);
> +      for (unsigned c = 0; c < op[0]->type->components(); c++) {
> +         data.i64[c] = op[0]->value.u64[c];
> +      }
> +      break;
>     case ir_unop_trunc:
>        for (unsigned c = 0; c < op[0]->type->components(); c++) {
>           if (op[0]->type->base_type == GLSL_TYPE_DOUBLE)
> @@ -776,6 +968,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = -op[0]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = -((int64_t)op[0]->value.u64[c]);
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = -op[0]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -799,6 +997,14 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = fabs(op[0]->value.d[c]);
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = op[0]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = op[0]->value.i64[c];
> +            if (data.i64[c] < 0)
> +               data.i64[c] = -data.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -820,6 +1026,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = double((op[0]->value.d[c] > 0)-(op[0]->value.d[c] < 0));
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = op[0]->value.i64[c] > 0;
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = (op[0]->value.i64[c] > 0) - (op[0]->value.i64[c] < 0);
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1006,6 +1218,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = MIN2(op[0]->value.d[c0], op[1]->value.d[c1]);
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = MIN2(op[0]->value.u64[c0], op[1]->value.u64[c1]);
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = MIN2(op[0]->value.i64[c0], op[1]->value.i64[c1]);
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1031,6 +1249,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = MAX2(op[0]->value.d[c0], op[1]->value.d[c1]);
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = MAX2(op[0]->value.u64[c0], op[1]->value.u64[c1]);
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = MAX2(op[0]->value.i64[c0], op[1]->value.i64[c1]);
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1056,6 +1280,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = op[0]->value.d[c0] + op[1]->value.d[c1];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = op[0]->value.u64[c0] + op[1]->value.u64[c1];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = op[0]->value.i64[c0] + op[1]->value.i64[c1];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1081,6 +1311,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.u64[c] = op[0]->value.u64[c0] - op[1]->value.u64[c1];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.i64[c] = op[0]->value.i64[c0] - op[1]->value.i64[c1];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1108,6 +1344,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>              case GLSL_TYPE_DOUBLE:
>                 data.d[c] = op[0]->value.d[c0] * op[1]->value.d[c1];
>                 break;
> +            case GLSL_TYPE_UINT64:
> +               data.u64[c] = op[0]->value.u64[c0] * op[1]->value.u64[c1];
> +               break;
> +            case GLSL_TYPE_INT64:
> +               data.i64[c] = op[0]->value.i64[c0] * op[1]->value.i64[c1];
> +               break;
>              default:
>                 assert(0);
>              }
> @@ -1169,6 +1411,20 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.d[c] = op[0]->value.d[c0] / op[1]->value.d[c1];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            if (op[1]->value.u64[c1] == 0) {
> +               data.u64[c] = 0;
> +            } else {
> +               data.u64[c] = op[0]->value.u64[c0] / op[1]->value.u64[c1];
> +            }
> +            break;
> +         case GLSL_TYPE_INT64:
> +            if (op[1]->value.i64[c1] == 0) {
> +               data.i64[c] = 0;
> +            } else {
> +               data.i64[c] = op[0]->value.i64[c0] / op[1]->value.i64[c1];
> +            }
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1211,6 +1467,20 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>              data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1]
>                 * floor(op[0]->value.d[c0] / op[1]->value.d[c1]);
>              break;
> +         case GLSL_TYPE_UINT64:
> +            if (op[1]->value.u64[c1] == 0) {
> +               data.u64[c] = 0;
> +            } else {
> +               data.u64[c] = op[0]->value.u64[c0] % op[1]->value.u64[c1];
> +            }
> +            break;
> +         case GLSL_TYPE_INT64:
> +            if (op[1]->value.i64[c1] == 0) {
> +               data.i64[c] = 0;
> +            } else {
> +               data.i64[c] = op[0]->value.i64[c0] % op[1]->value.i64[c1];
> +            }
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1250,6 +1520,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] < op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] < op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] < op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1271,6 +1547,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] > op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] > op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] > op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1292,6 +1574,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] <= op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] <= op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] <= op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1313,6 +1601,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] >= op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] >= op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] >= op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1337,6 +1631,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] == op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] == op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] == op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1361,6 +1661,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>           case GLSL_TYPE_DOUBLE:
>              data.b[c] = op[0]->value.d[c] != op[1]->value.d[c];
>              break;
> +         case GLSL_TYPE_UINT64:
> +            data.b[c] = op[0]->value.u64[c] != op[1]->value.u64[c];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            data.b[c] = op[0]->value.i64[c] != op[1]->value.i64[c];
> +            break;
>           default:
>              assert(0);
>           }
> @@ -1378,48 +1684,72 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>             c < components;
>             c0 += c0_inc, c1 += c1_inc, c++) {
>  
> -          if (op[0]->type->base_type == GLSL_TYPE_INT &&
> -              op[1]->type->base_type == GLSL_TYPE_INT) {
> -              data.i[c] = op[0]->value.i[c0] << op[1]->value.i[c1];
> -
> -          } else if (op[0]->type->base_type == GLSL_TYPE_INT &&
> -                     op[1]->type->base_type == GLSL_TYPE_UINT) {
> -              data.i[c] = op[0]->value.i[c0] << op[1]->value.u[c1];
> -
> -          } else if (op[0]->type->base_type == GLSL_TYPE_UINT &&
> -                     op[1]->type->base_type == GLSL_TYPE_INT) {
> -              data.u[c] = op[0]->value.u[c0] << op[1]->value.i[c1];
> -
> -          } else if (op[0]->type->base_type == GLSL_TYPE_UINT &&
> -                     op[1]->type->base_type == GLSL_TYPE_UINT) {
> -              data.u[c] = op[0]->value.u[c0] << op[1]->value.u[c1];
> -          }
> +         switch (op[0]->type->base_type) {
> +         case GLSL_TYPE_INT:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.i[c] = op[0]->value.i[c0] << op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.i[c] = op[0]->value.i[c0] << op[1]->value.u[c1];
> +            break;
> +         case GLSL_TYPE_UINT:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.u[c] = op[0]->value.u[c0] << op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.u[c] = op[0]->value.u[c0] << op[1]->value.u[c1];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.i64[c] = op[0]->value.i64[c0] << op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.i64[c] = op[0]->value.i64[c0] << op[1]->value.u[c1];
> +            break;
> +         case GLSL_TYPE_UINT64:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.u64[c] = op[0]->value.u64[c0] << op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.u64[c] = op[0]->value.u64[c0] << op[1]->value.u[c1];
> +            break;
> +         default:
> +            break;

I think this should be

               unreachable("first operand of shift must be integer type");

> +         }
>        }
>        break;
>  
>     case ir_binop_rshift:
> -       for (unsigned c = 0, c0 = 0, c1 = 0;
> -            c < components;
> -            c0 += c0_inc, c1 += c1_inc, c++) {
> +      for (unsigned c = 0, c0 = 0, c1 = 0;
> +           c < components;
> +           c0 += c0_inc, c1 += c1_inc, c++) {
>  
> -           if (op[0]->type->base_type == GLSL_TYPE_INT &&
> -               op[1]->type->base_type == GLSL_TYPE_INT) {
> +         switch (op[0]->type->base_type) {
> +         case GLSL_TYPE_INT:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
>                 data.i[c] = op[0]->value.i[c0] >> op[1]->value.i[c1];
> -
> -           } else if (op[0]->type->base_type == GLSL_TYPE_INT &&
> -                      op[1]->type->base_type == GLSL_TYPE_UINT) {
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
>                 data.i[c] = op[0]->value.i[c0] >> op[1]->value.u[c1];
> -
> -           } else if (op[0]->type->base_type == GLSL_TYPE_UINT &&
> -                      op[1]->type->base_type == GLSL_TYPE_INT) {
> +            break;
> +         case GLSL_TYPE_UINT:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
>                 data.u[c] = op[0]->value.u[c0] >> op[1]->value.i[c1];
> -
> -           } else if (op[0]->type->base_type == GLSL_TYPE_UINT &&
> -                      op[1]->type->base_type == GLSL_TYPE_UINT) {
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
>                 data.u[c] = op[0]->value.u[c0] >> op[1]->value.u[c1];
> -           }
> -       }
> -       break;
> +            break;
> +         case GLSL_TYPE_UINT64:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.u64[c] = op[0]->value.u64[c0] >> op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.u64[c] = op[0]->value.u64[c0] >> op[1]->value.u[c1];
> +            break;
> +         case GLSL_TYPE_INT64:
> +            if (op[1]->type->base_type == GLSL_TYPE_INT)
> +               data.i64[c] = op[0]->value.i64[c0] >> op[1]->value.i[c1];
> +            else if (op[1]->type->base_type == GLSL_TYPE_UINT)
> +               data.i64[c] = op[0]->value.i64[c0] >> op[1]->value.u[c1];
> +            break;
> +         default:
> +            break;

Same here.  With both of those changed, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> +         }
> +      }
> +      break;
>  
>     case ir_binop_bit_and:
>        for (unsigned c = 0, c0 = 0, c1 = 0;
> @@ -1433,6 +1763,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>            case GLSL_TYPE_UINT:
>                data.u[c] = op[0]->value.u[c0] & op[1]->value.u[c1];
>                break;
> +          case GLSL_TYPE_INT64:
> +              data.i64[c] = op[0]->value.i64[c0] & op[1]->value.i64[c1];
> +              break;
> +          case GLSL_TYPE_UINT64:
> +              data.u64[c] = op[0]->value.u64[c0] & op[1]->value.u64[c1];
> +              break;
>            default:
>                assert(0);
>            }
> @@ -1451,6 +1787,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>            case GLSL_TYPE_UINT:
>                data.u[c] = op[0]->value.u[c0] | op[1]->value.u[c1];
>                break;
> +          case GLSL_TYPE_INT64:
> +              data.i64[c] = op[0]->value.i64[c0] | op[1]->value.i64[c1];
> +              break;
> +          case GLSL_TYPE_UINT64:
> +              data.u64[c] = op[0]->value.u64[c0] | op[1]->value.u64[c1];
> +              break;
>            default:
>                assert(0);
>            }
> @@ -1495,6 +1837,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>            case GLSL_TYPE_UINT:
>                data.u[c] = op[0]->value.u[c0] ^ op[1]->value.u[c1];
>                break;
> +          case GLSL_TYPE_INT64:
> +              data.i64[c] = op[0]->value.i64[c0] ^ op[1]->value.i64[c1];
> +              break;
> +          case GLSL_TYPE_UINT64:
> +              data.u64[c] = op[0]->value.u64[c0] ^ op[1]->value.u64[c1];
> +              break;
>            default:
>                assert(0);
>            }
> @@ -1672,12 +2020,18 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
>  
>     case ir_triop_csel:
>        for (unsigned c = 0; c < components; c++) {
> -         if (op[1]->type->base_type == GLSL_TYPE_DOUBLE)
> -            data.d[c] = op[0]->value.b[c] ? op[1]->value.d[c]
> -                                       : op[2]->value.d[c];
> -         else
> +         switch (op[1]->type->base_type) {
> +         case GLSL_TYPE_UINT64:
> +         case GLSL_TYPE_INT64:
> +         case GLSL_TYPE_DOUBLE:
> +            data.u64[c] = op[0]->value.b[c] ? op[1]->value.u64[c]
> +                                       : op[2]->value.u64[c];
> +            break;
> +         default:
>              data.u[c] = op[0]->value.b[c] ? op[1]->value.u[c]
>                                         : op[2]->value.u[c];
> +            break;
> +         }
>        }
>        break;
>  
> 



More information about the mesa-dev mailing list