Re: [Mesa-dev] [PATCH 07/51] glsl: Add conversion ops to/from 16-bit floats

2017-11-27 Thread Matt Turner

On 11/24, Topi Pohjolainen wrote:

Signed-off-by: Topi Pohjolainen 
---
src/compiler/glsl/glsl_to_nir.cpp| 2 ++
src/compiler/glsl/ir.cpp | 8 
src/compiler/glsl/ir_expression_operation.py | 5 +
src/compiler/glsl/ir_validate.cpp| 8 
src/mesa/program/ir_to_mesa.cpp  | 2 ++
src/mesa/state_tracker/st_glsl_to_tgsi.cpp   | 3 +++
6 files changed, 28 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 289f8be031..14c358465b 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -1561,6 +1561,8 @@ nir_visitor::visit(ir_expression *ir)
   case ir_unop_d2b:
   case ir_unop_i2d:
   case ir_unop_u2d:
+   case ir_unop_h2f:
+   case ir_unop_f2h:
   case ir_unop_i642i:
   case ir_unop_i642u:
   case ir_unop_i642f:
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 2c61dd9d64..a901ec5683 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -281,6 +281,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_h2f:
   case ir_unop_bitcast_i2f:
   case ir_unop_bitcast_u2f:
   case ir_unop_i642f:
@@ -334,6 +335,13 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
  this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
   op0->type->vector_elements, 1);
  break;
+
+   case ir_unop_f2h:
+  this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16,
+  op0->type->vector_elements, 1);


Tabs on this line.


signature.asc
Description: Digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 07/51] glsl: Add conversion ops to/from 16-bit floats

2017-11-24 Thread Topi Pohjolainen
Signed-off-by: Topi Pohjolainen 
---
 src/compiler/glsl/glsl_to_nir.cpp| 2 ++
 src/compiler/glsl/ir.cpp | 8 
 src/compiler/glsl/ir_expression_operation.py | 5 +
 src/compiler/glsl/ir_validate.cpp| 8 
 src/mesa/program/ir_to_mesa.cpp  | 2 ++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   | 3 +++
 6 files changed, 28 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 289f8be031..14c358465b 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -1561,6 +1561,8 @@ nir_visitor::visit(ir_expression *ir)
case ir_unop_d2b:
case ir_unop_i2d:
case ir_unop_u2d:
+   case ir_unop_h2f:
+   case ir_unop_f2h:
case ir_unop_i642i:
case ir_unop_i642u:
case ir_unop_i642f:
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 2c61dd9d64..a901ec5683 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -281,6 +281,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_h2f:
case ir_unop_bitcast_i2f:
case ir_unop_bitcast_u2f:
case ir_unop_i642f:
@@ -334,6 +335,13 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
   this->type = glsl_type::get_instance(GLSL_TYPE_UINT64,
   op0->type->vector_elements, 1);
   break;
+
+   case ir_unop_f2h:
+  this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT16,
+  op0->type->vector_elements, 1);
+  break;
+
+
case ir_unop_noise:
   this->type = glsl_type::float_type;
   break;
diff --git a/src/compiler/glsl/ir_expression_operation.py 
b/src/compiler/glsl/ir_expression_operation.py
index d8542925a0..3158533c02 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -82,6 +82,7 @@ int_type = type("int", "i", "GLSL_TYPE_INT")
 uint64_type = type("uint64_t", "u64", "GLSL_TYPE_UINT64")
 int64_type = type("int64_t", "i64", "GLSL_TYPE_INT64")
 float_type = type("float", "f", "GLSL_TYPE_FLOAT")
+float16_t_type = type("float16_t_type", "f", "GLSL_TYPE_FLOAT16")
 double_type = type("double", "d", "GLSL_TYPE_DOUBLE")
 bool_type = type("bool", "b", "GLSL_TYPE_BOOL")
 
@@ -460,6 +461,10 @@ ir_expression_operation = [
operation("u2d", 1, source_types=(uint_type,), dest_type=double_type, 
c_expression="{src0}"),
# Double-to-boolean conversion.
operation("d2b", 1, source_types=(double_type,), dest_type=bool_type, 
c_expression="{src0} != 0.0"),
+   # hafl-to-float conversion.
+   operation("h2f", 1, source_types=(float16_t_type,), dest_type=float_type, 
c_expression="{src0}"),
+   # hafl-to-float conversion.
+   operation("f2h", 1, source_types=(float_type,), dest_type=float16_t_type, 
c_expression="{src0}"),
# 'Bit-identical int-to-float "conversion"
operation("bitcast_i2f", 1, source_types=(int_type,), dest_type=float_type, 
c_expression="bitcast_u2f({src0})"),
# 'Bit-identical float-to-int "conversion"
diff --git a/src/compiler/glsl/ir_validate.cpp 
b/src/compiler/glsl/ir_validate.cpp
index aa07f8aea6..29e3cda865 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -595,6 +595,14 @@ ir_validate::visit_leave(ir_expression *ir)
   assert(ir->operands[0]->type->is_double());
   assert(ir->type->is_boolean());
   break;
+   case ir_unop_h2f:
+  assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT16);
+  assert(ir->type->is_float());
+  break;
+   case ir_unop_f2h:
+  assert(ir->operands[0]->type->is_float());
+  assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
+  break;
 
case ir_unop_frexp_sig:
   assert(ir->operands[0]->type->is_float() ||
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index ac12389f70..d57e50366e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1313,6 +1313,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_unop_d2u:
case ir_unop_u2d:
case ir_unop_d2b:
+   case ir_unop_h2f:
+   case ir_unop_f2h:
case ir_unop_frexp_sig:
case ir_unop_frexp_exp:
   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 0772b73627..f8cb94c7dc 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1797,6 +1797,9 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, 
st_src_reg *op)
   else
  emit_asm(ir, TGSI_OPCODE_SNE, result_dst, op[0], 
st_src_reg_for_float(0.0));
   break;
+   case ir_unop_h2f:
+   case ir_unop_f2h:
+  unreachable("not implemented yet");
case ir_unop_bitcast_u642d:
case ir_unop_bitcast_i642d:
   result_src = op[0];
-- 
2.11.0

___