i965: Implement nir_op_fquantize2f16
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 12 Jan 2016 23:35:00 +0000 (15:35 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 12 Jan 2016 23:35:00 +0000 (15:35 -0800)
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp

index 62133784dcfb6a86f6d69205949b82b5dc242704..ffb805965b3d8052f0f9307c94d060afe4246849 100644 (file)
@@ -943,6 +943,19 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
       inst->saturate = instr->dest.saturate;
       break;
 
+   case nir_op_fquantize2f16: {
+      fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_D);
+
+      /* The destination stride must be at least as big as the source stride. */
+      tmp.type = BRW_REGISTER_TYPE_W;
+      tmp.stride = 2;
+
+      bld.emit(BRW_OPCODE_F32TO16, tmp, op[0]);
+      inst = bld.emit(BRW_OPCODE_F16TO32, result, tmp);
+      inst->saturate = instr->dest.saturate;
+      break;
+   }
+
    case nir_op_fmin:
    case nir_op_imin:
    case nir_op_umin:
index 37f517d4efd556a28854513c81623373bab75cf8..77a2f8b85fb5ed5a847486f44d99597106537888 100644 (file)
@@ -1177,6 +1177,16 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
       inst->saturate = instr->dest.saturate;
       break;
 
+   case nir_op_fquantize2f16: {
+      /* See also vec4_visitor::emit_pack_half_2x16() */
+      src_reg tmp = src_reg(this, glsl_type::uvec4_type);
+
+      emit(F32TO16(dst_reg(tmp), op[0]));
+      inst = emit(F16TO32(dst, tmp));
+      inst->saturate = instr->dest.saturate;
+      break;
+   }
+
    case nir_op_fmin:
    case nir_op_imin:
    case nir_op_umin: