Mesa (master): gallivm/nir: add quantize to f16 support
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 31 03:35:23 UTC 2020
Module: Mesa
Branch: master
Commit: 96a5ced65f6cfb666d040f3d75f40c6c5878946b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=96a5ced65f6cfb666d040f3d75f40c6c5878946b
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Jun 19 16:59:11 2020 +1000
gallivm/nir: add quantize to f16 support
Fixes:
dEQP-VK.spirv_assembly.instruction.graphics.opquantize.*
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6381>
---
src/gallium/auxiliary/gallivm/lp_bld_nir.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index 4c919e7a98f..99b35cfccd6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -441,6 +441,18 @@ do_int_mod(struct lp_build_nir_context *bld_base,
return LLVMBuildOr(builder, div_mask, result, "");
}
+static LLVMValueRef
+do_quantize_to_f16(struct lp_build_nir_context *bld_base,
+ LLVMValueRef src)
+{
+ struct gallivm_state *gallivm = bld_base->base.gallivm;
+ LLVMBuilderRef builder = gallivm->builder;
+ LLVMValueRef result;
+ result = LLVMBuildFPTrunc(builder, src, LLVMVectorType(LLVMHalfTypeInContext(gallivm->context), bld_base->base.type.length), "");
+ result = LLVMBuildFPExt(builder, result, bld_base->base.vec_type, "");
+ return result;
+}
+
static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
nir_op op, unsigned src_bit_size[NIR_MAX_VEC_COMPONENTS], LLVMValueRef src[NIR_MAX_VEC_COMPONENTS])
{
@@ -585,6 +597,9 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
case nir_op_fpow:
result = lp_build_pow(&bld_base->base, src[0], src[1]);
break;
+ case nir_op_fquantize2f16:
+ result = do_quantize_to_f16(bld_base, src[0]);
+ break;
case nir_op_frcp:
result = lp_build_rcp(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
break;
More information about the mesa-commit
mailing list