aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp2
-rw-r--r--src/compiler/glsl/ir.cpp6
-rw-r--r--src/compiler/glsl/ir_expression_operation.py6
-rw-r--r--src/compiler/glsl/ir_validate.cpp8
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
6 files changed, 26 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 8f15cd55fcb..0ebba46db80 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -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:
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index d9bc83501cd..dc832a2b632 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -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:
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
index d5c43e6e53a..df6a21f2202 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -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.
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index 80b0ce9efe1..f13bc6cd33d 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -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);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 4cd9abb9ce3..2f7b52c9d98 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -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;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 6c531ca5365..4871eb97545 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -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()");