[Mesa-dev] [PATCH] gallivm: some minor cube map cleanup

Jose Fonseca jfonseca at vmware.com
Thu Apr 4 12:43:16 PDT 2013


Looks good Roland.

----- Original Message -----
> From: Roland Scheidegger <sroland at vmware.com>
> 
> The ar_ge_as_at variable was just very very confusing since the condition
> was actually the other way around (as_at_ge_ar). So change the condition
> (and the selects depending on it) to match the variable name.
> Also, while here, change the chosen major axis in case the coord values
> are the same. OpenGL doesn't care one bit which one is chosen in this
> case but it looks like dx10 would require z chosen over y, and y chosen
> over x (previously did x chosen over y, y chosen over z). Since it's all
> the same effort just honor dx10's wishes.

It would be nice to have this paragraph in as a code comment too.

Jose

> ---
>  src/gallium/auxiliary/gallivm/lp_bld_sample.c |   21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> index fe29d25..734cfe0 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
> @@ -1403,12 +1403,13 @@ lp_build_cube_lookup(struct lp_build_sample_context
> *bld,
>        signr = LLVMBuildAnd(builder, ri, signmask, "");
>  
>        /*
> -       * major face determination: select x if x >= y else select y
> -       * select previous result if y >= max(x,y) else select z
> +       * major face determination: select x if x > y else select y
> +       * select z if z >= max(x,y) else select previous result
> +       * if some axis are the same we chose z over y, y over x.
>         */
> -      as_ge_at = lp_build_cmp(coord_bld, PIPE_FUNC_GEQUAL, as, at);
> +      as_ge_at = lp_build_cmp(coord_bld, PIPE_FUNC_GREATER, as, at);
>        maxasat = lp_build_max(coord_bld, as, at);
> -      ar_ge_as_at = lp_build_cmp(coord_bld, PIPE_FUNC_GEQUAL, maxasat, ar);
> +      ar_ge_as_at = lp_build_cmp(coord_bld, PIPE_FUNC_GEQUAL, ar, maxasat);
>  
>        /*
>         * compute all possible new s/t coords
> @@ -1449,13 +1450,13 @@ lp_build_cube_lookup(struct lp_build_sample_context
> *bld,
>           dmaxtnew = lp_build_select(coord_bld, as_ge_at, dmax[1], dmax[2]);
>        }
>  
> -      *face_s = lp_build_select(cint_bld, ar_ge_as_at, *face_s, snewz);
> -      *face_t = lp_build_select(cint_bld, ar_ge_as_at, *face_t, tnewz);
> -      ma = lp_build_select(coord_bld, ar_ge_as_at, ma, r);
> -      *face = lp_build_select(cint_bld, ar_ge_as_at, *face, facez);
> +      *face_s = lp_build_select(cint_bld, ar_ge_as_at, snewz, *face_s);
> +      *face_t = lp_build_select(cint_bld, ar_ge_as_at, tnewz, *face_t);
> +      ma = lp_build_select(coord_bld, ar_ge_as_at, r, ma);
> +      *face = lp_build_select(cint_bld, ar_ge_as_at, facez, *face);
>        if (need_derivs) {
> -         dmaxsnew = lp_build_select(coord_bld, ar_ge_as_at, dmaxsnew,
> dmax[0]);
> -         dmaxtnew = lp_build_select(coord_bld, ar_ge_as_at, dmaxtnew,
> dmax[1]);
> +         dmaxsnew = lp_build_select(coord_bld, ar_ge_as_at, dmax[0],
> dmaxsnew);
> +         dmaxtnew = lp_build_select(coord_bld, ar_ge_as_at, dmax[1],
> dmaxtnew);
>        }
>  
>        *face_s = LLVMBuildBitCast(builder, *face_s,
> --
> 1.7.9.5
> 
> 


More information about the mesa-dev mailing list