glsl: Add IR conversion ops for 16-bit float types
Adds ir_unop_f162f and ir_unop_f2f16. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
This commit is contained in:
@@ -2037,6 +2037,8 @@ nir_visitor::visit(ir_expression *ir)
|
||||
case ir_unop_b2i64:
|
||||
case ir_unop_d2f:
|
||||
case ir_unop_f2d:
|
||||
case ir_unop_f162f:
|
||||
case ir_unop_f2f16:
|
||||
case ir_unop_d2i:
|
||||
case ir_unop_d2u:
|
||||
case ir_unop_d2b:
|
||||
|
||||
@@ -283,6 +283,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
case ir_unop_i2f:
|
||||
case ir_unop_u2f:
|
||||
case ir_unop_d2f:
|
||||
case ir_unop_f162f:
|
||||
case ir_unop_bitcast_i2f:
|
||||
case ir_unop_bitcast_u2f:
|
||||
case ir_unop_i642f:
|
||||
@@ -291,6 +292,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
|
||||
op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_f2f16:
|
||||
this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16,
|
||||
op0->type->vector_elements, 1);
|
||||
break;
|
||||
|
||||
case ir_unop_f2b:
|
||||
case ir_unop_i2b:
|
||||
case ir_unop_d2b:
|
||||
|
||||
@@ -452,6 +452,12 @@ ir_expression_operation = [
|
||||
operation("d2f", 1, source_types=(double_type,), dest_type=float_type, c_expression="{src0}"),
|
||||
# Float-to-double conversion.
|
||||
operation("f2d", 1, source_types=(float_type,), dest_type=double_type, c_expression="{src0}"),
|
||||
# Half-float conversions. These all operate on and return float types,
|
||||
# since the framework expands half to full float before calling in. We
|
||||
# still have to handle them here so that we can constant propagate through
|
||||
# them, but they are no-ops.
|
||||
operation("f2f16", 1, source_types=(float_type,), dest_type=float_type, c_expression="{src0}"),
|
||||
operation("f162f", 1, source_types=(float_type,), dest_type=float_type, c_expression="{src0}"),
|
||||
# Double-to-integer conversion.
|
||||
operation("d2i", 1, source_types=(double_type,), dest_type=int_type, c_expression="{src0}"),
|
||||
# Integer-to-double conversion.
|
||||
|
||||
@@ -579,6 +579,14 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(ir->type->is_double());
|
||||
break;
|
||||
case ir_unop_f162f:
|
||||
assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT16);
|
||||
assert(ir->type->is_float());
|
||||
break;
|
||||
case ir_unop_f2f16:
|
||||
assert(ir->operands[0]->type->is_float());
|
||||
assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
|
||||
break;
|
||||
case ir_unop_d2i:
|
||||
assert(ir->operands[0]->type->is_double());
|
||||
assert(ir->type->base_type == GLSL_TYPE_INT);
|
||||
|
||||
@@ -1347,6 +1347,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
|
||||
case ir_unop_atan:
|
||||
case ir_binop_atan2:
|
||||
case ir_unop_clz:
|
||||
case ir_unop_f162f:
|
||||
case ir_unop_f2f16:
|
||||
assert(!"not supported");
|
||||
break;
|
||||
|
||||
|
||||
@@ -2395,6 +2395,8 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
|
||||
case ir_binop_avg:
|
||||
case ir_binop_avg_round:
|
||||
case ir_binop_mul_32x16:
|
||||
case ir_unop_f162f:
|
||||
case ir_unop_f2f16:
|
||||
/* This operation is not supported, or should have already been handled.
|
||||
*/
|
||||
assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
|
||||
|
||||
Reference in New Issue
Block a user