[Mesa-dev] [PATCH] lp_build_lod_selector: Disable brilinear folding on explicit lod.
Jose Fonseca
jfonseca at vmware.com
Mon Jun 25 15:16:35 PDT 2012
----- Original Message -----
> On Mon, Jun 25, 2012 at 11:40:08AM -0700, Jose Fonseca wrote:
> > My thoughts too.
> >
> > Brilinear filtering provides a significant boost, and I don't see
> > why skip the optimization for explicit lod over implicit lods.
>
> Warning: code misread :-)
>
> Explicit lod does not need brilinear filtering because explicit lod
> is
> post log2. Brilinear is only about a faster log2, nothing else.
> Explicit lod only needs the integer/fractional part separation.
>
> The whole code is:
> if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
> if (!explicit_lod && !(gallivm_debug &
> GALLIVM_DEBUG_NO_BRILINEAR)) {
> lp_build_brilinear_lod(float_bld, lod, BRILINEAR_FACTOR,
> out_lod_ipart, out_lod_fpart);
> }
> else {
> lp_build_ifloor_fract(float_bld, lod, out_lod_ipart,
> out_lod_fpart);
> }
>
> lp_build_name(*out_lod_fpart, "lod_fpart");
> }
> else {
> *out_lod_ipart = lp_build_iround(float_bld, lod);
> }
>
> and you're not going to tell me that lp_build_brilinear_lod is faster
> than lp_build_ifloor_fract (especially since it includes it ;-)
Indeed lp_build_brilinear_lod is not faster than lp_build_ifloor_fract, but brilinear is faster, not because log is a faster approximation, but because it increases the odds that fract part is zero, which means that we can sample from a single mip level, instead of lerping between two mip levels.
I think you have a good point here -- lp_build_brilinear_lod is a log2 approximation which is wrong here and that's a great catch, -- but I have a point too: lp_build_ifloor_fract will slow down texture sampling.
Just like log2 and brilinear log2, we need a variant of ifloor_fract, that increases the probability of fract part being zero, essentially by applying a stair case transformation like:
____/
/
____/
/
____/
Jose
More information about the mesa-dev
mailing list