From: Brian Paul Date: Thu, 4 Mar 2010 17:50:26 +0000 (-0700) Subject: gallivm: added lp_build_fract() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=516bad2272aa9bb3c85516e0023ddd2ed236dcef;p=mesa.git gallivm: added lp_build_fract() --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 42ae9f6a22c..32f9e5201c5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -899,6 +899,19 @@ lp_build_ceil(struct lp_build_context *bld, } +/** + * Return fractional part of 'a' computed as a - floor(f) + * Typically used in texture coord arithmetic. + */ +LLVMValueRef +lp_build_fract(struct lp_build_context *bld, + LLVMValueRef a) +{ + assert(bld->type.floating); + return lp_build_sub(bld, a, lp_build_floor(bld, a)); +} + + /** * Convert to integer, through whichever rounding method that's fastest, * typically truncating toward zero. diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 866349d8cba..55385e3a66a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -148,6 +148,10 @@ LLVMValueRef lp_build_trunc(struct lp_build_context *bld, LLVMValueRef a); +LLVMValueRef +lp_build_fract(struct lp_build_context *bld, + LLVMValueRef a); + LLVMValueRef lp_build_ifloor(struct lp_build_context *bld, LLVMValueRef a);