X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fgallivm%2Flp_bld_conv.c;h=712ce5f92dca1607db2d8db2a7ca88961a72f5f5;hb=5ae31d7e1d3d51c7843571c63aa228f8ca9b879f;hp=ba51ff794f657da5b15d568b2f385120238f197a;hpb=e08114fed723ff5a873d2a3f6682c1c074574458;p=mesa.git diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c index ba51ff794f6..712ce5f92dc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c @@ -266,17 +266,19 @@ lp_build_clamped_float_to_unsigned_norm(struct gallivm_state *gallivm, else if (dst_width == (mantissa + 1)) { /* * The destination width matches exactly what can be represented in - * floating point (i.e., mantissa + 1 bits). So do a straight - * multiplication followed by casting. No further rounding is necessary. + * floating point (i.e., mantissa + 1 bits). Even so correct rounding + * still needs to be applied (only for numbers in [0.5-1.0] would + * conversion using truncation after scaling be sufficient). */ - double scale; + struct lp_build_context uf32_bld; + lp_build_context_init(&uf32_bld, gallivm, src_type); scale = (double)((1ULL << dst_width) - 1); res = LLVMBuildFMul(builder, src, lp_build_const_vec(gallivm, src_type, scale), ""); - res = LLVMBuildFPToSI(builder, res, int_vec_type, ""); + res = lp_build_iround(&uf32_bld, res); } else { /*