In doing some testing we’ve noticed that trying to draw pixel aligned textures does not work very well with linear filtering in llvmpipe.

Here’s an example of the problem.

Imagine wanting to paint a 100x100 texture. After being scaled by 100 the texture coordinates will end up as:
0.5, 1.5, 2.5, 3.5, 4.5..

These are then multiplied by 256 and converted to integers giving us:
128, 384, 640, 896, 1152..

We subtract the 128:
0, 256, 512, 768, 1024..

Then mask to get the fractional component and shift to get the integer component:
0,0, 1,0, 2,0, 3,0, 4,0...

However, if for example 3.5 ends up as 3.4999999 we get:
895.9999744 -> 895 -> 767 -> 2,255 instead of 3,0

When we lerp using this value we end up including some of the pixel value at 2 instead of just at 3.

If we add 0.5 before converting to an integer this problem goes away.

The attached patch does this. It also changes the REPEAT mode code to use similar integer conversion code as the non-REPEAT path. The new generated code should be more efficient than the old code.

-Jeff

Attachment: add-0.5-before-converting-to-integer.patch
Description: Binary data

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to