radeonsi: use a faster version of PK2H
authorMarek Olšák <marek.olsak@amd.com>
Sat, 19 Aug 2017 20:51:51 +0000 (22:51 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 22 Aug 2017 11:29:47 +0000 (13:29 +0200)
+ 4 piglit regressions, but it's correct accorcing to the GL spec and
performance is more important than piglit.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c

index 12f8de405641ce97a1b5b2151297eec3e1abac3b..405469dd284d8fa2c42b216b8b9ac15c04dff2bc 100644 (file)
@@ -656,27 +656,14 @@ static void emit_pk2h(const struct lp_build_tgsi_action *action,
                      struct lp_build_tgsi_context *bld_base,
                      struct lp_build_emit_data *emit_data)
 {
-       LLVMBuilderRef builder = bld_base->base.gallivm->builder;
-       LLVMContextRef context = bld_base->base.gallivm->context;
-       struct lp_build_context *uint_bld = &bld_base->uint_bld;
-       LLVMTypeRef fp16, i16;
-       LLVMValueRef const16, comp[2];
-       unsigned i;
-
-       fp16 = LLVMHalfTypeInContext(context);
-       i16 = LLVMInt16TypeInContext(context);
-       const16 = lp_build_const_int32(uint_bld->gallivm, 16);
-
-       for (i = 0; i < 2; i++) {
-               comp[i] = LLVMBuildFPTrunc(builder, emit_data->args[i], fp16, "");
-               comp[i] = LLVMBuildBitCast(builder, comp[i], i16, "");
-               comp[i] = LLVMBuildZExt(builder, comp[i], uint_bld->elem_type, "");
-       }
-
-       comp[1] = LLVMBuildShl(builder, comp[1], const16, "");
-       comp[0] = LLVMBuildOr(builder, comp[0], comp[1], "");
-
-       emit_data->output[emit_data->chan] = comp[0];
+       /* From the GLSL 4.50 spec:
+        *   "The rounding mode cannot be set and is undefined."
+        *
+        * v_cvt_pkrtz_f16 rounds to zero, but it's fastest.
+        */
+       emit_data->output[emit_data->chan] =
+               ac_build_cvt_pkrtz_f16(&si_shader_context(bld_base)->ac,
+                                      emit_data->args);
 }
 
 static void up2h_fetch_args(struct lp_build_tgsi_context *bld_base,