gallivm: added lp_build_fract()
authorBrian Paul <brianp@vmware.com>
Thu, 4 Mar 2010 17:50:26 +0000 (10:50 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 4 Mar 2010 17:53:27 +0000 (10:53 -0700)
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_arit.h

index 42ae9f6a22c3c76dd7530e4cd1f67f9e838db248..32f9e5201c54fa566c0e02eb67f450290594d0f2 100644 (file)
@@ -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.
index 866349d8cbae1bf5d421850a511b7909770b4ce5..55385e3a66ad34c3aee0d0b6a600dafed535d3fe 100644 (file)
@@ -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);