summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-09-25 13:09:25 -0600
committerBrian Paul <brianp@vmware.com>2010-09-25 13:37:05 -0600
commit4e2f53bacb670b824593dce70668a8f92796ed93 (patch)
tree951fa5b7e32fbcd81c7d725b90a84662517d6da2 /src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
parente31f0f996537046228602a251706613ca4163209 (diff)
gallivm: fix repeat() function for NPOT textures
The trick of casting the coord to an unsigned value only works for POT textures. Add a bias instead. This fixes a few piglit texwrap failures.
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
index 9a1c693d5e..49a6eed615 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
@@ -90,10 +90,12 @@ lp_build_sample_wrap_nearest_int(struct lp_build_sample_context *bld,
case PIPE_TEX_WRAP_REPEAT:
if(is_pot)
coord = LLVMBuildAnd(bld->builder, coord, length_minus_one, "");
- else
- /* Signed remainder won't give the right results for negative
- * dividends but unsigned remainder does.*/
+ else {
+ /* Add a bias to the texcoord to handle negative coords */
+ LLVMValueRef bias = lp_build_mul_imm(uint_coord_bld, length, 1024);
+ coord = LLVMBuildAdd(bld->builder, coord, bias, "");
coord = LLVMBuildURem(bld->builder, coord, length, "");
+ }
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -197,8 +199,9 @@ lp_build_sample_wrap_linear_int(struct lp_build_sample_context *bld,
coord0 = LLVMBuildAnd(bld->builder, coord0, length_minus_one, "");
}
else {
- /* Signed remainder won't give the right results for negative
- * dividends but unsigned remainder does.*/
+ /* Add a bias to the texcoord to handle negative coords */
+ LLVMValueRef bias = lp_build_mul_imm(uint_coord_bld, length, 1024);
+ coord0 = LLVMBuildAdd(bld->builder, coord0, bias, "");
coord0 = LLVMBuildURem(bld->builder, coord0, length, "");
}