gallivm: check for level=0 case in lp_build_minify()
authorBrian Paul <brianp@vmware.com>
Thu, 30 Sep 2010 16:52:26 +0000 (10:52 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 30 Sep 2010 16:53:30 +0000 (10:53 -0600)
This lets us avoid the shift and max() operations.

src/gallium/auxiliary/gallivm/lp_bld_sample.c

index d9fbbbe70f759ec685510bbd1cfcfaf350da692a..6e53bca269a839d44282ac72801aaf552fc44763 100644 (file)
@@ -362,9 +362,16 @@ lp_build_minify(struct lp_build_sample_context *bld,
                 LLVMValueRef base_size,
                 LLVMValueRef level)
 {
-   LLVMValueRef size = LLVMBuildLShr(bld->builder, base_size, level, "minify");
-   size = lp_build_max(&bld->int_coord_bld, size, bld->int_coord_bld.one);
-   return size;
+   if (level == bld->int_coord_bld.zero) {
+      /* if we're using mipmap level zero, no minification is needed */
+      return base_size;
+   }
+   else {
+      LLVMValueRef size =
+         LLVMBuildLShr(bld->builder, base_size, level, "minify");
+      size = lp_build_max(&bld->int_coord_bld, size, bld->int_coord_bld.one);
+      return size;
+   }
 }