[Mesa-dev] [PATCH 2/3] gallivm: add uint to float arit function.
Jose Fonseca
jfonseca at vmware.com
Fri Feb 17 14:01:47 PST 2012
Note that SSE doesn't have vectorized UI to FP. Only SI to FP. At one point LLVM was breaking down the conversion to scalar, which is overkill. I think that since I look at it, LLVM has been updated to generate better code. Please take a look generated assembly for LLVMBuildUIToFP before commiting. Otherwise put a XXX comment warning about this so that we don't forget about this issue.
I'd prefer to have this one in lp_bld_conv.c . Because eventually this function will be superseeded by lp_build_conv().
The reason I don't recommend you to simply use lp_build_conv() is that lp_build_conv doesn't do the right thing with unsigned ints due to the issue above, and in many places (e.g., texture sampling), it doesn't matter. This needs to be cleaned up so that uint -> fp is done properly, and places that don't need uints don't use them.
Jose
----- Original Message -----
> From: Dave Airlie <airlied at redhat.com>
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/gallium/auxiliary/gallivm/lp_bld_arit.c | 15 +++++++++++++++
> src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 ++++
> 2 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> index f3e8ae4..1b97722 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> @@ -991,6 +991,21 @@ lp_build_int_to_float(struct lp_build_context
> *bld,
> return LLVMBuildSIToFP(builder, a, vec_type, "");
> }
>
> +/**
> + * Convert vector of (or scalar) uint to vector of (or scalar)
> float.
> + */
> +LLVMValueRef
> +lp_build_uint_to_float(struct lp_build_context *bld,
> + LLVMValueRef a)
> +{
> + LLVMBuilderRef builder = bld->gallivm->builder;
> + const struct lp_type type = bld->type;
> + LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
> +
> + assert(type.floating);
> +
> + return LLVMBuildUIToFP(builder, a, vec_type, "");
> +}
>
>
> enum lp_build_round_sse41_mode
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
> b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
> index c78b61d..0c753b7 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
> @@ -137,6 +137,10 @@ lp_build_int_to_float(struct lp_build_context
> *bld,
> LLVMValueRef a);
>
> LLVMValueRef
> +lp_build_uint_to_float(struct lp_build_context *bld,
> + LLVMValueRef a);
> +
> +LLVMValueRef
> lp_build_round(struct lp_build_context *bld,
> LLVMValueRef a);
>
> --
> 1.7.7.6
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list