summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-09-21 15:25:31 -0600
committerBrian Paul <[email protected]>2010-09-21 15:31:32 -0600
commitffa2d203fb71d54dc8dfa5d17aa1637d2f2bb5b5 (patch)
tree244f98db3eb5a51f80d7ee1d44f48959b907cd1f /src/gallium/auxiliary
parent83ea4878db8768b6e8444492009d80247d4374b7 (diff)
gallivm: fix lp_build_sample_compare()
The old code didn't really make sense. We only need to compare the X channel of the texture (depth) against the texcoord. For (bi)linear sampling we should move the calls to this function and compute the final result as (s1+s2+s3+s4) * 0.25. Someday. This fixes the glean glsl1 shadow2D() tests. See fd.o bug 29307.
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index f86d0553c7d..91fab18e4e6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -47,6 +47,7 @@
#include "lp_bld_arit.h"
#include "lp_bld_bitarit.h"
#include "lp_bld_logic.h"
+#include "lp_bld_printf.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_flow.h"
#include "lp_bld_gather.h"
@@ -1057,6 +1058,11 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
}
+/**
+ * Do shadow test/comparison.
+ * \param p the texcoord Z (aka R, aka P) component
+ * \param texel the texel to compare against (use the X channel)
+ */
static void
lp_build_sample_compare(struct lp_build_sample_context *bld,
LLVMValueRef p,
@@ -1064,30 +1070,30 @@ lp_build_sample_compare(struct lp_build_sample_context *bld,
{
struct lp_build_context *texel_bld = &bld->texel_bld;
LLVMValueRef res;
- unsigned chan;
+ const unsigned chan = 0;
- if(bld->static_state->compare_mode == PIPE_TEX_COMPARE_NONE)
+ if (bld->static_state->compare_mode == PIPE_TEX_COMPARE_NONE)
return;
- /* TODO: Compare before swizzling, to avoid redundant computations */
- res = NULL;
- for(chan = 0; chan < 4; ++chan) {
- LLVMValueRef cmp;
- cmp = lp_build_cmp(texel_bld, bld->static_state->compare_func, p, texel[chan]);
- cmp = lp_build_select(texel_bld, cmp, texel_bld->one, texel_bld->zero);
-
- if(res)
- res = lp_build_add(texel_bld, res, cmp);
- else
- res = cmp;
+ /* debug code */
+ if (0) {
+ LLVMValueRef indx = lp_build_const_int32(0);
+ LLVMValueRef coord = LLVMBuildExtractElement(bld->builder, p, indx, "");
+ LLVMValueRef tex = LLVMBuildExtractElement(bld->builder,
+ texel[chan], indx, "");
+ lp_build_printf(bld->builder, "shadow compare coord %f to texture %f\n",
+ coord, tex);
}
- assert(res);
- res = lp_build_mul(texel_bld, res, lp_build_const_vec(texel_bld->type, 0.25));
+ /* result = (p FUNC texel) ? 1 : 0 */
+ res = lp_build_cmp(texel_bld, bld->static_state->compare_func,
+ p, texel[chan]);
+ res = lp_build_select(texel_bld, res, texel_bld->one, texel_bld->zero);
/* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */
- for(chan = 0; chan < 3; ++chan)
- texel[chan] = res;
+ texel[0] =
+ texel[1] =
+ texel[2] = res;
texel[3] = texel_bld->one;
}