[Mesa-dev] [PATCH 09/23] glsl/ir: add support for 64-bit integer conversions.

Ian Romanick idr at freedesktop.org
Thu Jun 9 19:01:53 UTC 2016


On 06/08/2016 05:48 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This adds all the conversions in the world, I'm not 100%
> sure of all of these are needed, but add all of them and
> we can cut them down later.

I think we'll probably need them all.  A couple of trivial comments
below.  With those fixed, this patch is

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

> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/glsl/ir.cpp          |  82 +++++++++++++++++++++++++
>  src/compiler/glsl/ir.h            |  38 +++++++++++-
>  src/compiler/glsl/ir_validate.cpp | 124 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 242 insertions(+), 2 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
> index a7c0eac..47846f7 100644
> --- a/src/compiler/glsl/ir.cpp
> +++ b/src/compiler/glsl/ir.cpp
> @@ -261,6 +261,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>     case ir_unop_find_msb:
>     case ir_unop_find_lsb:
>     case ir_unop_subroutine_to_int:
> +   case ir_unop_i642i:
> +   case ir_unop_u642i:
>        this->type = glsl_type::get_instance(GLSL_TYPE_INT,
>  					   op0->type->vector_elements, 1);
>        break;
> @@ -271,6 +273,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>     case ir_unop_d2f:
>     case ir_unop_bitcast_i2f:
>     case ir_unop_bitcast_u2f:
> +   case ir_unop_i642f:
> +   case ir_unop_u642f:
>        this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
>  					   op0->type->vector_elements, 1);
>        break;
> @@ -278,6 +282,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>     case ir_unop_f2b:
>     case ir_unop_i2b:
>     case ir_unop_d2b:
> +   case ir_unop_i642b:
> +   case ir_unop_u642b:
>        this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
>  					   op0->type->vector_elements, 1);
>        break;
> @@ -285,6 +291,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>     case ir_unop_f2d:
>     case ir_unop_i2d:
>     case ir_unop_u2d:
> +   case ir_unop_i642d:
> +   case ir_unop_u642d:
>        this->type = glsl_type::get_instance(GLSL_TYPE_DOUBLE,
>  					   op0->type->vector_elements, 1);
>        break;
> @@ -293,15 +301,36 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>     case ir_unop_f2u:
>     case ir_unop_d2u:
>     case ir_unop_bitcast_f2u:
> +   case ir_unop_i642u:
> +   case ir_unop_u642u:
>        this->type = glsl_type::get_instance(GLSL_TYPE_UINT,
>  					   op0->type->vector_elements, 1);
>        break;
>  
> +   case ir_unop_i2i64:
> +   case ir_unop_u2i64:
> +   case ir_unop_b2i64:
> +   case ir_unop_f2i64:
> +   case ir_unop_d2i64:
> +      this->type = glsl_type::get_instance(GLSL_TYPE_INT64,
> +					   op0->type->vector_elements, 1);
> +      break;
> +
> +   case ir_unop_i2u64:
> +   case ir_unop_u2u64:
> +   case ir_unop_b2u64:
> +   case ir_unop_f2u64:
> +   case ir_unop_d2u64:
> +      this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
> +					   op0->type->vector_elements, 1);
> +      break;
>     case ir_unop_noise:
>        this->type = glsl_type::float_type;
>        break;
>  
>     case ir_unop_unpack_double_2x32:
> +   case ir_unop_unpack_int_2x32:
> +   case ir_unop_unpack_uint_2x32:
>        this->type = glsl_type::uvec2_type;
>        break;
>  
> @@ -317,6 +346,14 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>        this->type = glsl_type::double_type;
>        break;
>  
> +   case ir_unop_pack_int_2x32:
> +      this->type = glsl_type::int64_t_type;
> +      break;
> +
> +   case ir_unop_pack_uint_2x32:
> +      this->type = glsl_type::uint64_t_type;
> +      break;
> +
>     case ir_unop_unpack_snorm_2x16:
>     case ir_unop_unpack_unorm_2x16:
>     case ir_unop_unpack_half_2x16:
> @@ -347,6 +384,21 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
>        this->type = glsl_type::bool_type;
>        break;
>  
> +   case ir_unop_bitcast_i642d:
> +   case ir_unop_bitcast_u642d:
> +      this->type = glsl_type::get_instance(GLSL_TYPE_DOUBLE,
> +                                           op0->type->vector_elements, 1);
> +      break;
> +
> +   case ir_unop_bitcast_d2i64:
> +      this->type = glsl_type::get_instance(GLSL_TYPE_INT64,
> +                                           op0->type->vector_elements, 1);
> +      break;
> +   case ir_unop_bitcast_d2u64:
> +      this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
> +                                           op0->type->vector_elements, 1);
> +      break;
> +
>     default:
>        assert(!"not reached: missing automatic type setup for ir_expression");
>        this->type = op0->type;
> @@ -532,6 +584,32 @@ static const char *const operator_strs[] = {
>     "bitcast_f2i",
>     "bitcast_u2f",
>     "bitcast_f2u",
> +   "bitcast_u642d",
> +   "bitcast_i642d",
> +   "bitcast_d2u64",
> +   "bitcast_d2i64",
> +   "i642i",
> +   "u642i",
> +   "i642u",
> +   "u642u",
> +   "i642b",
> +   "u642b",
> +   "i642f",
> +   "u642f",
> +   "i642d",
> +   "u642d",
> +   "i2i64",
> +   "u2i64",
> +   "b2i64",
> +   "f2i64",
> +   "d2i64",
> +   "i2u64",
> +   "u2u64",
> +   "b2u64",
> +   "f2u64",
> +   "d2u64",
> +   "i642u64",
> +   "u642i64",
>     "trunc",
>     "ceil",
>     "floor",
> @@ -572,6 +650,10 @@ static const char *const operator_strs[] = {
>     "vote_any",
>     "vote_all",
>     "vote_eq",
> +   "packInt2x32",
> +   "unpackInt2x32",
> +   "packUint2x32",
> +   "unpackUint2x32",
>     "+",
>     "-",
>     "*",
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index 5a325c2..8dc257e 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -1383,7 +1383,32 @@ enum ir_expression_operation {
>     ir_unop_bitcast_f2i, /**< Bit-identical float-to-int "conversion" */
>     ir_unop_bitcast_u2f, /**< Bit-identical uint-to-float "conversion" */
>     ir_unop_bitcast_f2u, /**< Bit-identical float-to-uint "conversion" */
> -
> +   ir_unop_bitcast_u642d, /**< Bit-identical u64-to-double "conversion" */
> +   ir_unop_bitcast_i642d, /**< Bit-identical i64-to-double "conversion" */
> +   ir_unop_bitcast_d2u64, /**< Bit-identical double-to_u64 "conversion" */
> +   ir_unop_bitcast_d2i64, /**< Bit-identical double-to-i64 "conversion" */
> +   ir_unop_i642i,        /**< i64-to-i32 conversion */
> +   ir_unop_u642i,        /**< ui64-to-i32 conversion */
> +   ir_unop_i642u,
> +   ir_unop_u642u,
> +   ir_unop_i642b,
> +   ir_unop_u642b,
> +   ir_unop_i642f,
> +   ir_unop_u642f,
> +   ir_unop_i642d,
> +   ir_unop_u642d,
> +   ir_unop_i2i64,
> +   ir_unop_u2i64,
> +   ir_unop_b2i64,
> +   ir_unop_f2i64,
> +   ir_unop_d2i64,
> +   ir_unop_i2u64,
> +   ir_unop_u2u64,
> +   ir_unop_b2u64,
> +   ir_unop_f2u64,
> +   ir_unop_d2u64,
> +   ir_unop_u642i64,
> +   ir_unop_i642u64,

Blank line here.

>     /**
>      * \name Unary floating-point rounding operations.
>      */
> @@ -1489,9 +1514,18 @@ enum ir_expression_operation {
>     ir_unop_vote_eq,
>  
>     /**
> +    * 64-bit integer packing ops.
> +    */
> +   ir_unop_pack_int_2x32,
> +   ir_unop_unpack_int_2x32,
> +   ir_unop_pack_uint_2x32,
> +   ir_unop_unpack_uint_2x32,
> +   /*@}*/

I don't think this Doxygen @} should be here.  Rebase issue?

> +
> +   /**
>      * A sentinel marking the last of the unary operations.
>      */
> -   ir_last_unop = ir_unop_vote_eq,
> +   ir_last_unop = ir_unop_unpack_uint_2x32,
>  
>     ir_binop_add,
>     ir_binop_sub,
> diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
> index 126f9bf..91a83c2 100644
> --- a/src/compiler/glsl/ir_validate.cpp
> +++ b/src/compiler/glsl/ir_validate.cpp
> @@ -320,6 +320,110 @@ ir_validate::visit_leave(ir_expression *ir)
>        assert(ir->type->base_type == GLSL_TYPE_UINT);
>        break;
>  
> +   case ir_unop_bitcast_u642d:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
> +      break;
> +   case ir_unop_bitcast_i642d:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
> +      break;
> +   case ir_unop_bitcast_d2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_bitcast_d2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_i642i:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_INT);
> +      break;
> +   case ir_unop_u642i:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_INT);
> +      break;
> +   case ir_unop_i642u:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT);
> +      break;
> +   case ir_unop_u642u:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT);
> +      break;
> +   case ir_unop_i642b:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_BOOL);
> +      break;
> +   case ir_unop_u642b:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_BOOL);
> +      break;
> +   case ir_unop_i642f:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_FLOAT);
> +      break;
> +   case ir_unop_u642f:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_FLOAT);
> +      break;
> +   case ir_unop_i642d:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
> +      break;
> +   case ir_unop_u642d:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
> +      break;
> +   case ir_unop_i2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_u2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_b2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_f2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_d2i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
> +   case ir_unop_i2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_u2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_b2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_f2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_d2u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_u642i64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT64);
> +      break;
> +   case ir_unop_i642u64:
> +      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
> +      assert(ir->type->base_type == GLSL_TYPE_INT64);
> +      break;
>     case ir_unop_trunc:
>     case ir_unop_round_even:
>     case ir_unop_ceil:
> @@ -359,6 +463,16 @@ ir_validate::visit_leave(ir_expression *ir)
>        assert(ir->operands[0]->type == glsl_type::uvec2_type);
>        break;
>  
> +   case ir_unop_pack_int_2x32:
> +      assert(ir->type == glsl_type::int64_t_type);
> +      assert(ir->operands[0]->type == glsl_type::uvec2_type);
> +      break;
> +
> +   case ir_unop_pack_uint_2x32:
> +      assert(ir->type == glsl_type::uint64_t_type);
> +      assert(ir->operands[0]->type == glsl_type::uvec2_type);
> +      break;
> +
>     case ir_unop_unpack_snorm_2x16:
>     case ir_unop_unpack_unorm_2x16:
>     case ir_unop_unpack_half_2x16:
> @@ -377,6 +491,16 @@ ir_validate::visit_leave(ir_expression *ir)
>        assert(ir->operands[0]->type == glsl_type::double_type);
>        break;
>  
> +   case ir_unop_unpack_int_2x32:
> +      assert(ir->type == glsl_type::uvec2_type);
> +      assert(ir->operands[0]->type == glsl_type::int64_t_type);
> +      break;
> +
> +   case ir_unop_unpack_uint_2x32:
> +      assert(ir->type == glsl_type::uvec2_type);
> +      assert(ir->operands[0]->type == glsl_type::uint64_t_type);
> +      break;
> +
>     case ir_unop_bitfield_reverse:
>        assert(ir->operands[0]->type == ir->type);
>        assert(ir->type->is_integer());
> 



More information about the mesa-dev mailing list