Mesa (master): gallivm: fix f16 quantize.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 3 21:46:13 UTC 2020


Module: Mesa
Branch: master
Commit: ad3849259a88de04367857765f4b8d56d62dacbc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad3849259a88de04367857765f4b8d56d62dacbc

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Oct 23 16:04:04 2020 +1000

gallivm: fix f16 quantize.

Add the correct flush to 0 behaviour.

Fixes:
dEQP-VK.spirv_assembly.instruction.compute.opquantize.flush_to_zero

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7416>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 23e57809385..c8d864a2803 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -504,9 +504,18 @@ do_quantize_to_f16(struct lp_build_nir_context *bld_base,
 {
    struct gallivm_state *gallivm = bld_base->base.gallivm;
    LLVMBuilderRef builder = gallivm->builder;
-   LLVMValueRef result;
+   LLVMValueRef result, cond, cond2, temp;
+
    result = LLVMBuildFPTrunc(builder, src, LLVMVectorType(LLVMHalfTypeInContext(gallivm->context), bld_base->base.type.length), "");
    result = LLVMBuildFPExt(builder, result, bld_base->base.vec_type, "");
+
+   temp = lp_build_abs(get_flt_bld(bld_base, 32), result);
+   cond = LLVMBuildFCmp(builder, LLVMRealOGT,
+                        LLVMBuildBitCast(builder, lp_build_const_int_vec(gallivm, bld_base->uint_bld.type, 0x38800000), bld_base->base.vec_type, ""),
+                        temp, "");
+   cond2 = LLVMBuildFCmp(builder, LLVMRealONE, temp, bld_base->base.zero, "");
+   cond = LLVMBuildAnd(builder, cond, cond2, "");
+   result = LLVMBuildSelect(builder, cond, bld_base->base.zero, result, "");
    return result;
 }
 



More information about the mesa-commit mailing list