gallivm: fix out-of-bounds access with mirror_clamp_to_edge address mode
authorRoland Scheidegger <sroland@vmware.com>
Sat, 1 Jun 2013 00:17:09 +0000 (02:17 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Sat, 1 Jun 2013 18:03:59 +0000 (20:03 +0200)
commit458a9a0f85b93e3520c33dd3b502e26a31f08e4b
tree2721267f4483f28f2e1f9c1d0e96fcb8104fab93
parentf51fc7a71c272ad28e157d1d8f642649c3b5487b
gallivm: fix out-of-bounds access with mirror_clamp_to_edge address mode

Surprising this bug survived so long, we were missing a clamp (in the
linear filtering version).
(Valgrind complained a lot about invalid reads with piglit texwrap,
I've also seen spurios failures in this test which might have
happened due to this. Valgrind probably didn't complain before the
alignment reduction in llvmpipe to 4x4 since the test is using tiny
textures so the reads were still always well within allocated area.)
While here, also do an effective clamp (after half subtraction)
of [0,length-0.5] instead of [0, length-1] which saves an instruction
(the filtering weight could be different due to this, but only if
both texels point to the same max texel so it doesn't matter).
(Both changes are borrowed from PIPE_TEX_CLAMP_TO_EDGE case.)

Note: This is a candidate for the stable branches.

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