From: Neil Roberts Date: Wed, 9 Oct 2019 11:07:40 +0000 (+0200) Subject: glsl: Add ir_unop_f2fmp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1b8edffaa5816449436fac981fd27005fcede8c9;p=mesa.git glsl: Add ir_unop_f2fmp This is the same as ir_unop_f2f16 except that it comes with a promise that it is safe to optimise it out if the result is immediately converted back to float32 again. Normally this would be a lossy operation but it is safe to do if the conversion was generated as part of the precision lowering pass. Reviewed-by: Marek Olšák Reviewed-by: Ian Romanick Part-of: --- diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 6d82fcae6d2..d8fbc804ff0 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -2079,6 +2079,11 @@ nir_visitor::visit(ir_expression *ir) break; } + case ir_unop_f2fmp: { + result = nir_build_alu(&b, nir_op_f2fmp, srcs[0], NULL, NULL, NULL); + break; + } + case ir_unop_bitcast_i2f: case ir_unop_bitcast_f2i: case ir_unop_bitcast_u2f: diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index 4df511fbf8d..4d4bc0fb957 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -293,6 +293,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0) break; case ir_unop_f2f16: + case ir_unop_f2fmp: case ir_unop_b2f16: this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16, op0->type->vector_elements, 1); diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py index 48fbc873e93..5fcc9ee9ab4 100644 --- a/src/compiler/glsl/ir_expression_operation.py +++ b/src/compiler/glsl/ir_expression_operation.py @@ -459,6 +459,7 @@ ir_expression_operation = [ # 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("f2fmp", 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}"), diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp index 02a5f3dec56..4c4948c30ca 100644 --- a/src/compiler/glsl/ir_validate.cpp +++ b/src/compiler/glsl/ir_validate.cpp @@ -593,6 +593,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type->is_float()); break; case ir_unop_f2f16: + case ir_unop_f2fmp: assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_FLOAT16); break; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ee7741b8755..adb8720c622 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1349,6 +1349,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_unop_clz: case ir_unop_f162f: case ir_unop_f2f16: + case ir_unop_f2fmp: case ir_unop_f162b: case ir_unop_b2f16: assert(!"not supported"); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index e53bed93f6b..31ffa24958c 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2397,6 +2397,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) case ir_binop_mul_32x16: case ir_unop_f162f: case ir_unop_f2f16: + case ir_unop_f2fmp: case ir_unop_f162b: case ir_unop_b2f16: /* This operation is not supported, or should have already been handled.