From 9eef86bb55108bfe2537d90e7efb41a30bf8547a Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 4 Apr 2013 23:20:49 +0200 Subject: gallivm: some minor cube map cleanup 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 --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index fe29d258c9d..7f44c4e64a2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -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, -- cgit v1.2.3