OSDN Git Service

gallivm: some minor cube map cleanup
authorRoland Scheidegger <sroland@vmware.com>
Thu, 4 Apr 2013 21:20:49 +0000 (23:20 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 4 Apr 2013 21:22:10 +0000 (23:22 +0200)
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.
And also 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. (Though actually, for some prefered
orderings, we could save one (or two with derivatives) selects since the
tnewx and tnewz (and the corresponding dmax values) are the same.)

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_sample.c

index fe29d25..7f44c4e 100644 (file)
@@ -1403,12 +1403,17 @@ 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 - the
+       * dx10 spec seems to ask for it while OpenGL doesn't care (if we
+       * wouldn't care could save a select or two if using different
+       * compares and doing at_g_as_ar last since tnewx and tnewz are the
+       * same).
        */
-      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 +1454,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,