Mesa (master): gallivm: don't apply zero lod_bias

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Oct 6 18:06:26 UTC 2010


Module: Mesa
Branch: master
Commit: 5849a6ab6412eddd4552329178e6edb0bea92977
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5849a6ab6412eddd4552329178e6edb0bea92977

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Sep 30 16:43:56 2010 +0100

gallivm: don't apply zero lod_bias

---

 src/gallium/auxiliary/gallivm/lp_bld_sample.c |    7 ++++++-
 src/gallium/auxiliary/gallivm/lp_bld_sample.h |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index acd9974..2227a06 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -132,6 +132,10 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
       state->min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
    }
 
+   if (sampler->lod_bias != 0.0) {
+      state->lod_bias_non_zero = 1;
+   }
+
    /* If min_lod == max_lod we can greatly simplify mipmap selection.
     * This is a case that occurs during automatic mipmap generation.
     */
@@ -258,7 +262,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
       }
 
       /* add sampler lod bias */
-      lod = LLVMBuildFAdd(bld->builder, lod, sampler_lod_bias, "sampler_lod_bias");
+      if (bld->static_state->lod_bias_non_zero)
+         lod = LLVMBuildFAdd(bld->builder, lod, sampler_lod_bias, "sampler_lod_bias");
 
       /* clamp lod */
       lod = lp_build_clamp(float_bld, lod, min_lod, max_lod);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 4d2eeaa..bb1c8c8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -83,6 +83,7 @@ struct lp_sampler_static_state
    unsigned compare_func:3;
    unsigned normalized_coords:1;
    unsigned min_max_lod_equal:1;  /**< min_lod == max_lod ? */
+   unsigned lod_bias_non_zero:1;
 };
 
 




More information about the mesa-commit mailing list